Option #1: Try invalidateOptionsMenu()
. I don't know if this will force an immediate redraw of the action bar or not.
Option #2: See if getActionView()
returns anything for the affected MenuItem
. It is possible that showAsAction
simply automatically creates action views for you. If so, you can presumably enable/disable that View
.
I can't seem to find a way to get the currently set Menu to manipulate it except for in onPrepareOptionMenu.
You can hang onto the Menu
object you were handed in onCreateOptionsMenu()
. Quoting the docs:
You can safely hold on to menu (and any items created from it), making modifications to it as desired, until the next time onCreateOptionsMenu() is called.