gpt4 book ai didi

android - 无法找到明确的 Activity (Kotlin)

转载 作者:行者123 更新时间:2023-11-29 01:05:05 25 4
gpt4 key购买 nike

我进行了一项新 Activity ,当我尝试通过单击按钮在它们之间移动时,应用程序崩溃并且 logcat 显示以下错误

    12-16 14:02:09.016 23235-23235/com.modather.scalculate E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.modather.scalculate, PID: 23235
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.modather.scalculate/android.support.v7.widget.AppCompatButton}; have you declared this activity in your AndroidManifest.xml?
at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java)
at android.app.Instrumentation.execStartActivity(Instrumentation.java)
at android.app.Activity.startActivityForResult(Activity.java)
at android.support.v4.app.BaseFragmentActivityApi16.startActivityForResult(BaseFragmentActivityApi16.java:54)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:67)
at android.app.Activity.startActivityForResult(Activity.java)
at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:720)
at android.app.Activity.startActivity(Activity.java)
at android.app.Activity.startActivity(Activity.java)
at com.modather.scalculate.HomePage$onCreate$1.onClick(HomePage.kt:36)
at android.view.View.performClick(View.java)
at android.view.View$PerformClick.run(View.java)
at android.os.Handler.handleCallback(Handler.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:107)

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity
android:name=".HomePage"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.modather.scalculate.age"
android:label="Calculate my age(SC)" />
</application>

我搜索了 stackoverflow 并找到了一些解决方案,但它对我不起作用..所以如果可以修复我的问题?这是移动代码

fab.setOnClickListener {
val intent = Intent(this, activity_age::class.java)
startActivity(intent)
}

最佳答案

有打字错误检查一下

您的 Activity 名称是 activity_age 并且您在 list 中添加的 age

fab.setOnClickListener {
val intent = Intent(this,age::class.java)
startActivity(intent)
}

关于android - 无法找到明确的 Activity (Kotlin),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47845615/

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