[FIXED] How to disable a particular option from optionmenu across all the tabs in android?


I am developing an application which consists of four tabs. Its also having six optionmenu which is common to all the four tabs and I need to disable one of the option menu depending on the current state of the application. Is there any way to disable particular option from the optionmenu across all the tabs??


To disable a menu item, you can override onPrepareOptionsMenu in your activity:

public boolean onPrepareOptionsMenu(Menu menu) {

    // To disable the item

    // To make the item invisible

If your tabs are composed of multiple views, then you only need to override the method in one place. If your tabs are composed of multiple activities, then you’ll need to override the method in each of your activities and choose which items to display based on your application’s state.

Answered By – Erich Douglass

Answer Checked By – Senaida (Easybugfix Volunteer)

Leave a Reply

(*) Required, Your email will not be published