Reputation: 824
I am using the onCreateOptionsMenu
and there is a default menu item that I did not program. I would like to remove it because I have no use for it and it does not do anything. Here is what it looks like:
I would like to get rid of the "Settings" item.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(1, 1, 0, "item1");
menu.add(1, 2, 1, "item2");
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.activity_name, menu);
return true;
}
As you can see, I have not manually added it myself. How do I get rid of it?
Upvotes: 1
Views: 6007
Reputation: 1026
The settings option is automatically generated in the menu xml by eclipse. Remove it from the xml menu and that option will be no longer shown.
Upvotes: 2
Reputation: 1006549
As you can see, I have not added it myself
Yes, you have. It is coming from:
getMenuInflater().inflate(R.menu.activity_name, menu);
How do I get rid of it?
Remove the aforementioned line. Or, move your Java-based Menu
manipulations to res/menu/activity_name.xml
and get rid of "Settings" from that file.
Upvotes: 4
Reputation: 2088
check the content of R.menu.activity_name or past the data of this xml file.
Upvotes: 0