Android action bar - disable options menu

9.4k views Asked by At

How can I disable options menu item from my action bar?

I made my own custom bar, for display *.png logo, but i don't want to display three dots button of options menu.

I've tried to find some solution, but nothing works.

4

There are 4 answers

0
Yash Sampat On BEST ANSWER

Code Monkey's answer will do what you want, but as a side effect it will also not allow you to add ANY action items to the Action Bar at all. I believe the correct answer is

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

This is what you want.

0
code monkey On

Simply remove the public boolean onCreateOptionsMenu(Menu menu) method from your Activity.

0
Michele La Ferla On

In the java class containing the code for the app you are developing, all you need 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 generated in your project by default. That's why you need to remove it.

Hope this helps :)

0
temp On

If you want this, not necessary Override onCreateOptionsMenu method in your activity.
Leave it with empty block.