gpt4 book ai didi

android - Unresolved reference 'Intent' : val intent = Intent

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:26:11 31 4
gpt4 key购买 nike

我确信有一些显而易见的事情,但还没有找到解决这个简单问题的方法。错误是在用户猜出正确答案时尝试启动另一个 Activity 的主要 Activity :

Error:(85, 23) Unresolved reference: Intent

代码来自“Kotlin Development for Android”一书中的 High/Low Android 应用程序。

val intent = Intent("com.example.user.highlow2.CorrectGuessActivity")
startActivity(intent)

list 具有以下用于调用 Activity 的 Intent 过滤器:

<intent-filter>
<action android:name="com.example.user.highlow2.CorrectGuessActivity"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>

最佳答案

原始语法和建议都产生了相同的错误。 MainActivity 需要以下内容才能识别 Intent: 导入 android.content.Intent

关于android - Unresolved reference 'Intent' : val intent = Intent,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48873594/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com