1

我有两节课。主类是BundleActivity,还有一个子类。我正在尝试从 BundleActivity 启动子活动,但它不起作用并且应用程序正在强制关闭。

这是我在 BundleAcitvity 类中的 onClick 方法:

public void onClick(View v) {
        // TODO Auto-generated method stub

            Intent i=new Intent(this,sub.class);
            this.startActivity(i);
                            }

我的清单文件:

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

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
          <activity
            android:name=".BundleActivity"
            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=".sub"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.bundle.sub" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

    </application>

</manifest>

有人帮我解决吗?

4

1 回答 1

0

您是否为您的子活动创建了一个类?据我所知,您所有的课程都必须以大写字母“Sub”开头。对我来说,感觉就像您不需要放入子活动中的意图过滤器一样。

您没有收到任何预编译错误吗?运行时的错误跟踪是什么?

于 2012-08-26T11:24:25.440 回答