Add menu item using SpannableString

I add a SpannableString to the menu item as the name of the item, but after clicking this menu I get the following exception:

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) 
+6
source share
1 answer

Try overriding onMenuItemSelected and instead

return super.onMenuItemSelected (featureId, item). use return true

0
source

Source: https://habr.com/ru/post/921706/


All Articles