當該應用程序啓動時(公共布爾onCreateOptionsMenu(菜單菜單)),該代碼在logcat中失敗。任何人都可以請指出爲什麼如此?意外的文檔結尾(在android.view.MenuInflater.parseMenu)
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.official, menu);
official_menu = menu.findItem(R.id.ac_official);
important_menu = menu.findItem(R.id.ac_important);
normal_menu = menu.findItem(R.id.ac_normal);
create_menu = menu.findItem(R.id.ac_create);
if(dp.getDesignation().equalsIgnoreCase("student")){
create_menu.setVisible(false);
}
profile_menu = menu.findItem(R.id.ac_profile);
return true;
}
logcat的
01-20 06:59:19.684: E/AndroidRuntime(996): FATAL EXCEPTION: main
01-20 06:59:19.684: E/AndroidRuntime(996): java.lang.RuntimeException: Unexpected end of document
01-20 06:59:19.684: E/AndroidRuntime(996): at android.view.MenuInflater.parseMenu(MenuInflater.java:197)
01-20 06:59:19.684: E/AndroidRuntime(996): at android.view.MenuInflater.inflate(MenuInflater.java:110)
01-20 06:59:19.684: E/AndroidRuntime(996): at com.notice.official.OfficialActivity.onCreateOptionsMenu(OfficialActivity.java:183)
01-20 06:59:19.684: E/AndroidRuntime(996): at android.app.Activity.onCreatePanelMenu(Activity.java:2504)
01-20 06:59:19.684: E/AndroidRuntime(996): at com.android.internal.policy.impl.PhoneWindow.preparePanel(PhoneWindow.java:413)
01-20 06:59:19.684: E/AndroidRuntime(996): at com.android.internal.policy.impl.PhoneWindow.doInvalidatePanelMenu(PhoneWindow.java:775)
01-20 06:59:19.684: E/AndroidRuntime(996): at com.android.internal.policy.impl.PhoneWindow$1.run(PhoneWindow.java:198)
01-20 06:59:19.684: E/AndroidRuntime(996): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
01-20 06:59:19.684: E/AndroidRuntime(996): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
01-20 06:59:19.684: E/AndroidRuntime(996): at android.view.Choreographer.doFrame(Choreographer.java:531)
01-20 06:59:19.684: E/AndroidRuntime(996): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
01-20 06:59:19.684: E/AndroidRuntime(996): at android.os.Handler.handleCallback(Handler.java:730)
01-20 06:59:19.684: E/AndroidRuntime(996): at android.os.Handler.dispatchMessage(Handler.java:92)
01-20 06:59:19.684: E/AndroidRuntime(996): at android.os.Looper.loop(Looper.java:137)
01-20 06:59:19.684: E/AndroidRuntime(996): at android.app.ActivityThread.main(ActivityThread.java:5103)
01-20 06:59:19.684: E/AndroidRuntime(996): at java.lang.reflect.Method.invokeNative(Native Method)
01-20 06:59:19.684: E/AndroidRuntime(996): at java.lang.reflect.Method.invoke(Method.java:525)
01-20 06:59:19.684: E/AndroidRuntime(996): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
01-20 06:59:19.684: E/AndroidRuntime(996): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
01-20 06:59:19.684: E/AndroidRuntime(996): at dalvik.system.NativeStart.main(Native Method)
的例外似乎是在'com.notice.official.OfficialActivity.onCreateOptionsMenu(OfficialActivity.java:183)'。你可能試圖從'R.menu'中誇大畸形的XML文件嗎? – Nachi
畸形?如在? –
'意外的文檔結束'意味着XML無效。也許有些標籤沒有正確關閉? – Nachi