出于某种原因,我无法从我的意图中找到这个类,我收到了这个错误:
Unable to find explicit activity class {com.example.ruchirb.tutorial/com.example.ruchirb.tutorial.myIntro}; have you declared this activity in your AndroidManifest.xml?
当我尝试开始我的活动时会发生这种情况:
Intent i = new Intent(MainActivity.this, myIntro.class);
startActivity(i);
我 在我的清单中声明了它:
<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>
我没有该类的布局,因为我正在尝试使用此库制作介绍教程:
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.
}
}
问题是什么?
谢谢,
Ruchir
答案 0 :(得分:2)
语法中有错误。在第一项活动中宣布了第二项活动。所有活动必须仅在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"
/>
应该像上面一样。