2016-03-12 46 views
0

出于某种原因,我无法找到我的意图类,而我得到这个错误:不能找到课程?

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

回答

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" 

/> 

应该像上面那样。