0

Intent を使用して新しいアクティビティに移動しようとしています。私のコードは次のとおりです。

Button button = (Button)this.findViewById(R.id.deviceinit);

button.setOnClickListener(new OnClickListener(){
            public void onClick(View v) {
                Intent intent = new Intent(ANDROIDPORTINGActivity.this,Central.class);
                startActivity(intent);
            }
})

新しいクラスを作成しましたCentral。しかし、ボタンをクリックすると、FORCED CLOSED! というエラー メッセージが表示されます。別のアクティビティに移動するための提案はありますか?

4

2 に答える 2

3

セントラルもアクティビティである必要があり、AndroidManifest.xmlさらに

   <activity
        android:name=".Central">
        <intent-filter>
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
于 2012-05-10T12:12:41.317 に答える
2

Centralにアクティビティが含まれていることを確認してくださいAndroidManifest.xml

アプリ マニフェストの詳細: http://developer.android.com/guide/topics/manifest/manifest-intro.html

于 2012-05-10T12:10:03.063 に答える