Reputation: 55
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.
Upvotes: 3
Views: 9482
Reputation: 30611
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.
Upvotes: 6
Reputation: 56
If you want this, not necessary Override onCreateOptionsMenu
method in your activity.
Leave it with empty block.
Upvotes: 2
Reputation: 6884
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 :)
Upvotes: 2
Reputation: 2124
Simply remove the public boolean onCreateOptionsMenu(Menu menu)
method from your Activity.
Upvotes: 3