【问题标题】:Cant find class?找不到课?
【发布时间】:2016-03-12 19:46:15
【问题描述】:

由于某种原因,我无法从我的意图中找到该类,并收到此错误:

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.
    }

}

可能是什么问题?

谢谢,

鲁基尔

【问题讨论】:

    标签: java android xml string algorithm


    【解决方案1】:

    您的语法有误。第二个活动是在第一个活动中声明的。所有活动必须仅在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"
    
     />
    

    应该和上面一样。

    【讨论】:

      猜你喜欢
      • 2012-11-08
      • 1970-01-01
      • 2017-01-20
      • 1970-01-01
      • 2014-12-19
      • 2016-12-02
      • 2014-09-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多