I can easily do it when I am using onCreateOptionsMenu
or onOptionsItemSelected
methods.
But I have a button somewhere in screen, and on clicking that button, it should enable/disable context menu items.
androidcontextmenumenuitem
I can easily do it when I am using onCreateOptionsMenu
or onOptionsItemSelected
methods.
But I have a button somewhere in screen, and on clicking that button, it should enable/disable context menu items.
Best Answer
Anyway, the documentation covers all the things.
Changing menu items at runtime
E.g.
On Android 3.0 and higher, the options menu is considered to always be open when menu items are presented in the action bar. When an event occurs and you want to perform a menu update, you must call
invalidateOptionsMenu()
to request that the system callonPrepareOptionsMenu()
.