所以我想切換意見使用意圖,我已經能夠得到這個工作之前,但現在它只是繼續關閉,這也是通過菜單按鈕,繼承人我的菜單代碼:我的意圖是不工作的android
public boolean onCreateOptionsMenu(android.view.Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater blowUp = getMenuInflater();
blowUp.inflate(R.menu.menu, menu);
return true;
}
public boolean onOptionsItemSelected(MenuItem item){
switch(item.getItemId()){
case R.id.stats:
Intent i = new Intent("com.mittereder.rockpaper.STATS");
startActivity(i);
break;
}
return false;
}
這是我的菜單包含項目:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/stats"
android:alphabeticShortcut="s"
android:title="Stats"/>
</menu>
那麼這裏是我的清單:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mittereder.rockpaper"
android:versionCode="2"
android:versionName="1.2" >
<uses-sdk android:minSdkVersion="8" />
<application
android:icon="@drawable/stop"
android:label="@string/app_name" >
<activity
android:name=".start"
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=".stats"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.mittereder.rockpaper.STATS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
我一遍又一遍地檢查了我的代碼,我不知道我錯過了什麼。
的logcat:
08-09 11:51:11.471: E/AndroidRuntime(13384): FATAL EXCEPTION: main
08-09 11:51:11.471: E/AndroidRuntime(13384): android.app.SuperNotCalledException: Activity {com.mittereder.rockpaper/com.mittereder.rockpaper.start} did not call through to super.onPause()
08-09 11:51:11.471: E/AndroidRuntime(13384): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3103)
08-09 11:51:11.471: E/AndroidRuntime(13384): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:3062)
08-09 11:51:11.471: E/AndroidRuntime(13384): at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3035)
08-09 11:51:11.471: E/AndroidRuntime(13384): at android.app.ActivityThread.access$800(ActivityThread.java:139)
08-09 11:51:11.471: E/AndroidRuntime(13384): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1268)
08-09 11:51:11.471: E/AndroidRuntime(13384): at android.os.Handler.dispatchMessage(Handler.java:99)
08-09 11:51:11.471: E/AndroidRuntime(13384): at android.os.Looper.loop(Looper.java:154)
08-09 11:51:11.471: E/AndroidRuntime(13384): at android.app.ActivityThread.main(ActivityThread.java:4945)
08-09 11:51:11.471: E/AndroidRuntime(13384): at java.lang.reflect.Method.invokeNative(Native Method)
08-09 11:51:11.471: E/AndroidRuntime(13384): at java.lang.reflect.Method.invoke(Method.java:511)
08-09 11:51:11.471: E/AndroidRuntime(13384): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-09 11:51:11.471: E/AndroidRuntime(13384): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-09 11:51:11.471: E/AndroidRuntime(13384): at dalvik.system.NativeStart.main(Native Method)
logcat將幫助任何錯誤消息。 – Kaediil 2012-08-09 15:47:45
@Kaediil在 – 2012-08-09 15:54:19