6

我将 SpannableString 作为项目名称添加到菜单项,但是单击此菜单后,出现以下异常:

FATAL EXCEPTION: main
        java.lang.IllegalArgumentException: Invalid payload item type
        at android.util.EventLog.writeEvent(Native Method)
        at android.app.Activity.onMenuItemSelected(Activity.java:2306)
        at com.android.internal.policy.impl.PhoneWindow.onMenuItemSelected(PhoneWindow.java:830)
        at com.android.internal.view.menu.MenuItemImpl.invoke(MenuItemImpl.java:160)
        at com.android.internal.view.menu.MenuBuilder.performItemAction(MenuBuilder.java:885)
        at com.android.internal.view.menu.IconMenuView.invokeItem(IconMenuView.java:545)
        at com.android.internal.view.menu.IconMenuItemView.performClick(IconMenuItemView.java:122)
        at android.view.View$PerformClick.run(View.java:9320)
        at android.os.Handler.handleCallback(Handler.java:587)
        at android.os.Handler.dispatchMessage(Handler.java:92)
        at android.os.Looper.loop(Looper.java:150)
        at android.app.ActivityThread.main(ActivityThread.java:4385)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:507)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
        at dalvik.system.NativeStart.main(Native Method)
4

1 回答 1

0

尝试覆盖,onMenuItemSelected而不是

返回 super.onMenuItemSelected(featureId, item)。使用返回真

于 2013-10-12T20:43:31.307 回答