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

Central 也应该是一项活动,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 回答