[英]Unable to find explicit activity class have you declared this activity in your AndroidManifest.xml?
I want to open next activity but having following error 我想打开下一个活动,但出现以下错误
android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.pc.lovequoteandcalculator/int};
android.content.ActivityNotFoundException:无法找到显式的活动类{com.example.pc.lovequoteandcalculator / int}; have you declared this activity in your AndroidManifest.xml?
您是否在AndroidManifest.xml中声明了此活动?
My Manifest.xml is 我的Manifest.xml是
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.pc.lovequoteandcalculator">
<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=".MainActivity">
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".lovecalculate" />
<activity android:name=".quoteforlove" />
<activity android:name=".quotestoimpress"></activity>
</application>
And this is how I am starting new activity 这就是我开始新活动的方式
val btn = findViewById<View>(R.id.btnlovecal) as Button btn.setOnClickListener {
startActivity(
Intent(this@MainActivity,activity_lovecalculate::class.java)
)
}
Can someone point out what am I missing here? 有人可以指出我在这里想念什么吗?
You seem to calling the wrong activity with the following: 您似乎通过以下方式调用了错误的活动:
Intent(this@MainActivity,activity_lovecalculate::class.java)
which is trying to call activity_lovecalculate
activity. 试图调用
activity_lovecalculate
活动。 But you only have: 但是您只有:
<activity android:name=".lovecalculate" />
So, try using lovecalculate
with something like this: 因此,尝试使用
lovecalculate
进行以下操作:
val btn = findViewById<View>(R.id.btnlovecal) as Button btn.setOnClickListener {
startActivity(
Intent(this@MainActivity, lovecalculate::class.java)
)
}
PS: Please use a correct coding style for class name. PS:请对类名使用正确的编码样式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.