即使在清单文件中声明了活动,活动也不会开始

时间:2014-11-01 12:54:33

标签: android

我有一项不会开始的活动。

收到的错误是:

android.content.ActivityNotFoundException:无法找到显式活动类{com.example.its_time / com.example.its_time.actiongenre.ActioncomedyActivity};你有没有在AndroidManifest.xml中声明这个活动?

我已经检查过,活动是在清单文件中声明的。

为什么我的声明仍然会出现这个错误?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.its_time"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="21" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".mainmenu.MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity
            android:name=".mainmenu.NextactivityActivity"
            android:label="@string/title_activity_nextactivity" >
        </activity>
        <activity
            android:name=".mainmenu.Next100moviesActivity"
            android:label="@string/title_activity_next100movies" >
        </activity>
        <activity
            android:name=".mainmenu.NextTvSeriesActivity"
            android:label="@string/title_activity_next_tv_series" >
        </activity>
        <activity
            android:name=".top100list.Top100listActivity"
            android:label="@string/title_activity_top100list" >
        </activity>
        <activity
            android:name=".top100list.ThegodfatherActivity"
            android:label="@string/title_activity_thegodfather" >
        </activity>
        <activity
            android:name=".moviegenres.ActiongenreActivity"
            android:label="@string/title_activity_actiongenre" >
        </activity>
        <activity
            android:name=".moviegenres.ComedyActivity"
            android:label="@string/title_activity_comedy" >
        </activity>
        <activity
            android:name=".moviegenres.ScifiActivity"
            android:label="@string/title_activity_scifi" >
        </activity>
        <activity
            android:name=".moviegenres.AnimationActivity"
            android:label="@string/title_activity_animation" >
        </activity>
        <activity
            android:name=".moviegenres.DokumentaryActivity"
            android:label="@string/title_activity_dokumentary" >
        </activity>
        <activity
            android:name=".moviegenres.HorrorActivity"
            android:label="@string/title_activity_horror" >
        </activity>
        <activity
            android:name=".actiongenre.ScifiActivity"
            android:label="@string/title_activity_scifi" >
        </activity>
        <activity
            android:name=".moviegenres.Drama2Activity"
            android:label="@string/title_activity_drama2" >
        </activity>
        <activity
            android:name=".actiongenre.ActioncomedyActivity"
            android:label="@string/title_activity_actioncomedy" >
        </activity>
        <activity
            android:name=".actiongenre.AdventureActivity"
            android:label="@string/title_activity_adventure" >
        </activity>
        <activity
            android:name=".actiongenre.WesternActivity"
            android:label="@string/title_activity_western" >
        </activity>
        <activity
            android:name=".actiongenre.ActiondramaActivity"
            android:label="@string/title_activity_actiondrama" >
        </activity>
        <activity
            android:name=".actiongenre.ActionthrillerActivity"
            android:label="@string/title_activity_actionthriller" >
        </activity>
        <activity
            android:name=".actiongenre.ActionfantaasyActivity"
            android:label="@string/title_activity_actionfantaasy" >
        </activity>
        <activity
            android:name=".animationgenres.AnimationActionActivity"
            android:label="@string/title_activity_animation_action" >
        </activity>
        <activity
            android:name=".animationgenres.AnimadventureActivity"
            android:label="@string/title_activity_animadventure" >
        </activity>
        <activity
            android:name=".animationgenres.AnimcomedyActivity"
            android:label="@string/title_activity_animcomedy" >
        </activity>
        <activity
            android:name=".animationgenres.AnimdramaActivity"
            android:label="@string/title_activity_animdrama" >
        </activity>
        <activity
            android:name="comedygenres.ComedyromanceActivity"
            android:label="@string/title_activity_comedyromance" >
        </activity>
        <activity
            android:name="ancomedygenres.ComedydramaActivityramaActivity"
            android:label="@string/title_activity_comedydrama" >
        </activity>
        <activity
            android:name="comedygenres.ComedyactionActivitye.ComedyactionActivity"
            android:label="@string/title_activity_comedyaction" >
        </activity>
        <activity
            android:name="comedygenres.ComedycomedyActivitye.ComedycomedyActivity"
            android:label="@string/title_activity_comedycomedy" >
        </activity>
        <activity
            android:name=".documentarysubgenres.DocumentaryWarActivity"
            android:label="@string/title_activity_documentary_war" >
        </activity>
        <activity
            android:name=".documentarysubgenres.DocumentaryBiografiActivity"
            android:label="@string/title_activity_documentary_biografi" >
        </activity>
        <activity
            android:name=".DocumentaryMusikActivity"
            android:label="@string/title_activity_documentary_musik" >
        </activity>
        <activity
            android:name=".DocumentarySportActivity"
            android:label="andcom.example.its_time.documentarysubgenres.DocumentaryNatureActivityactivity_documentary_sport" >
        </activity>
        <activity
            android:name=".Doccom.example.its_time.documentarysubgenres.DocumentaryHistoryActivity"
            android:label="@string/title_activity_documentary_nature" >
        </activity>
        <activity
            android:name=".DocumentaryHistoryActivity"
            android:label="androcom.example.its_time.documentarysubgenres.DocumentaryDramaActivityctivity_documentary_history" >
        </activity>
        <activity
            android:name=".DocumentaryDramaActivity"
            android:label="@string/title_activity_documentary_drama" >
        </activity>
        <activity
            android:name=".documentarysubgenres.DocumentaryCultureAndPoliticsActivity"
            android:label="@string/title_activity_documentary_culture_and_politics" >
        </activity>
        <activity
            android:name=".DocumentaryBrottActivity"
            android:label="@string/title_activity_documentary_brott" >
        </activity>
        <activity
            android:name=".horrorsubgenres.HorrorThrillerActivity"
            android:label="@string/title_activity_horror_thriller" >
        </activity>
        <activity
            android:name=".HorrorHorrorActivity"
            android:label="@string/title_activity_horror_horror" >
        </activity>
        <activity
            android:name=".horrorsubgenres.HorrorScifiActivity"
            android:label="@string/title_activity_horror_scifi" >
        </activity>
        <activity
            android:name=".ScifiDramaActivity"
            android:label="@string/title_activity_scifi_drama" >
        </activity>
        <activity
            android:name=".ScifiThrillerActivity"
            android:label="@string/title_activity_scifi_thriller" >
        </activity>
        <activity
            android:name=".ScifiAdventureActivity"
            android:label="@string/title_activity_scifi_adventure" >
        </activity>
        <activity
            android:name=".ScifiActionActivity"
            android:label="@string/title_activity_scifi_action" >
        </activity>
        <activity
            android:name=".ScifiHorrorActivity"
            android:label="@string/title_activity_scifi_horror" >
        </activity>
        <activity
            android:name=".DramaSportActivity"
            android:label="@string/title_activity_drama_sport" >
        </activity>
        <activity
            android:name=".DramaComedyActivity"
            android:label="@string/title_activity_drama_comedy" >
        </activity>
        <activity
            android:name=".DramaAdventureActivity"
            android:label="@string/title_activity_drama_adventure" >
        </activity>
        <activity
            android:name=".DramaActionActivity"
            android:label="@string/title_activity_drama_action" >
        </activity>
        <activity
            android:name=".DramaDramaActivity"
            android:label="@string/title_activity_drama_drama" >
        </activity>
        <activity
            android:name=".DramaRomantikActivity"
            android:label="@string/title_activity_drama_romantik" >
        </activity>
        <activity
            android:name=".DramaThrillerActivity"
            android:label="@string/title_activity_drama_thriller" > 
        </activity>
    </application>

</manifest>

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.nextactivity);

        pupulateListView();
        registerClickCallback();
    }

    private void registerClickCallback() {
ListView list = (ListView)findViewById(R.id.listViewGenres);

        list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {

                Intent intent;
                switch(position)
                {
                case 0:
                    intent = new Intent(NextactivityActivity.this,ActiongenreActivity.class);
                    startActivity(intent);
                    break;
                case 1:
                    intent = new Intent(NextactivityActivity.this,AnimationActivity.class);
                    startActivity(intent);
                    break;
                case 2:
                    intent = new Intent(NextactivityActivity.this,ComedyActivity.class);
                    startActivity(intent);
                    break;
                case 3:
                    intent = new Intent(NextactivityActivity.this,DokumentaryActivity.class);
                    startActivity(intent);
                    break;
                case 4:
                    intent = new Intent(NextactivityActivity.this,HorrorActivity.class);
                    startActivity(intent);
                    break;
                case 5:
                    intent = new Intent(NextactivityActivity.this,ScifiActivity.class);
                    startActivity(intent);
                    break;
                case 6:
                    intent = new Intent(NextactivityActivity.this,Drama2Activity.class);
                    startActivity(intent);
                    break;
                default:
                    break;
                }

            }
        });

    }

    private void pupulateListView() {
        String[] myItems = {"Action","Animation","Komedi","Dokumentär","Skräck","Sci-fi","Drama"};

        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.the_list_genres,myItems);
        ListView list = (ListView)findViewById(R.id.listViewGenres);
        list.setAdapter(adapter);

    }


    }

这是第一段带我进入下一步的代码,这个过程有效

这是下一步的代码,它将带我进入第三步:

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.actiongenre);

        populateListView();
        registerClickCallback();

    }

    private void registerClickCallback() {

ListView list = (ListView)findViewById(R.id.listViewActionSubgenres);

        list.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {

                Intent intent;
                switch(position)
                {
                case 0:
                    intent = new Intent(ActiongenreActivity.this,Actioncomedyactivity.class);
                    startActivity(intent);
                    break;
                case 1:
                    intent = new Intent(ActiongenreActivity.this,Actionadventureactivity.class);
                    startActivity(intent);
                    break;
                case 2:
                    intent = new Intent(ActiongenreActivity.this,ActionWesternActivity.class);
                    startActivity(intent);
                    break;
                case 3:
                    intent = new Intent(ActiongenreActivity.this,ActiondramaActivity.class);
                    startActivity(intent);
                    break;
                case 4:
                    intent = new Intent(ActiongenreActivity.this,ActionthrillerActivity.class);
                    startActivity(intent);
                    break;
                case 5:
                    intent = new Intent(ActiongenreActivity.this,ActionfantaasyActivity.class);
                    startActivity(intent);
                    break;
                default:
                    break;
                }

            }
        });



    }
    private void populateListView() {
        String[] myItems = {"Komedi","Äventyr","Western","Drama","Thriller","Fantasi"};
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,R.layout.the_list,myItems);
        ListView list = (ListView)findViewById(R.id.listViewActionSubgenres);
        list.setAdapter(adapter);
    }


}

但它的第三步不起作用,你可以看到第一步的代码 过程几乎与第二个相同

2 个答案:

答案 0 :(得分:1)

只需替换此

  android:name=".actiongenre.ActioncomedyActivity"

将完整的包名称包含在ActionComedyActivity中,如下所示

  android:name="youCompletePackageName.Actioncomedyactivity"

答案 1 :(得分:0)

当代码Actioncomedyactivity时,您的代码为ActioncomedyActivityaA有关。