I'm trying to make one of the MenuItems
on my Menu
have a checkmark ability, but it doesn't seem to work. All other MenuItems
are working, this one does too, except for the checkmark display. What am I doing wrong?
MenuItem actionPickMode = menu.add(0, 3, 0, "pickmode");
actionPickMode.setTitle("Pick Mode");
actionPickMode.setShowAsAction(MenuItem.SHOW_AS_ACTION_WITH_TEXT
| MenuItem.SHOW_AS_ACTION_ALWAYS);
actionPickMode.setVisible(true);
actionPickMode.setCheckable(true);
Looks like you're trying to add a checkmark to a MenuItem
that is actually on the Action Bar. According to this question it isn't possible: Android action bar checkable menu item does not work/show properly?
What you can do is implement it yourself--when the item is clicked, use setIcon
to change the drawable, and maintain the state of the toggle yourself. This question describes how you can get the built-in checkmark Drawable
s: How to access checkmark drawable in Android OS?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With