出于某种原因,我无法从我的 Intent 中找到该类,并且出现此错误:
Unable to find explicit activity class {com.example.ruchirb.tutorial/com.example.ruchirb.tutorial.myIntro}; have you declared this activity in your AndroidManifest.xml?
它发生在我尝试开始我的 Activity 时:
Intent i = new Intent(MainActivity.this, myIntro.class);
startActivity(i);
而且我已经在我的 list 中声明了它:
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<activity //RIGHT HERE !!!!!!! SEE ITS DECLARED!!!
android:name=".myIntro"
android:label="@string/app_name"
/>
</activity>
</application>
我没有类(class)的布局,因为我正在尝试使用这个库制作介绍教程:
https://github.com/PaoloRotolo/AppIntro
这是我的 myIntro.class
的代码:
package com.example.ruchirb.tutorial;
import android.graphics.Color;
import android.os.Bundle;
import com.example.ruchirb.tutorial.R;
import com.github.paolorotolo.appintro.AppIntro;
import com.github.paolorotolo.appintro.AppIntroFragment;
public class myIntro extends AppIntro {
// Please DO NOT override onCreate. Use init.
@Override
public void init(Bundle savedInstanceState) {
// Add your slide's fragments here.
// AppIntro will automatically generate the dots indicator and buttons.
addSlide(AppIntroFragment.newInstance("Hello", "Sup bro", R.mipmap.ic_launcher, Color.RED));
addSlide(AppIntroFragment.newInstance("NUMBER 2", "Hello again", R.mipmap.ic_launcher, Color.BLUE));
// OPTIONAL METHODS
// Override bar/separator color.
setBarColor(Color.parseColor("#3F51B5"));
setSeparatorColor(Color.parseColor("#2196F3"));
// Hide Skip/Done button.
showSkipButton(false);
setProgressButtonEnabled(false);
// Turn vibration on and set intensity.
// NOTE: you will probably need to ask VIBRATE permisssion in Manifest.
setVibrate(true);
setVibrateIntensity(30);
}
@Override
public void onSkipPressed() {
// Do something when users tap on Skip button.
}
@Override
public void onDonePressed() {
// Do something when users tap on Done button.
}
@Override
public void onSlideChanged() {
// Do something when the slide changes.
}
@Override
public void onNextPressed() {
// Do something when users tap on Next button.
}
}
可能是什么问题?
谢谢,
鲁契尔
最佳答案
你的语法有误。第二个 Activity 在第一个 Activity 中宣布。所有 Activity 都必须仅在 application
下声明。
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity <!-- should be inside application not inside above activity -->
android:name=".myIntro"
android:label="@string/app_name"
/>
应该像上面那样。
关于java - 找不到类?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35962478/