Android action bar - disable options menu

How do I disable an option menu item from the action bar?

I made my own panel to display the * .png logo, but I don't want to display the 3-dot option menu button.

I tried to find some solution but nothing seems to work.

+3


source to share


4 answers


Monkey's answer code will do what you want, but as a side effect, it also won't let you add ANY items to the action bar at all. I believe the correct answer is

@Override
public boolean onPrepareOptionsMenu (Menu menu) {
    return false;
}

      



Is this what you want.

+5


source


Just remove the method public boolean onCreateOptionsMenu(Menu menu)

from your activity.



+3


source


In the java class containing the code for the application you are developing, all you have to do is remove the following method:

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    inflater.inflate(R.menu.main, menu);
}

      

This is automatically created in your default project. This is why you need to remove it.

Hope it helps :)

+2


source


If you want this, there is no need to override the method onCreateOptionsMenu

in your activity.
Leave this with an empty block.

+2


source







All Articles