2016-03-12 72 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" 

/> 

應該像上面那樣。