How do I remove the settings icon from the top-right of the action bar? When I emulate on my actual Samsung galaxy s3 phone, it is not there, however, when I emulate on an AVD for the Nexus 7, it appears. Here is the code for my menu:
<menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/action_settings" android:orderInCategory="100" android:showAsAction="never" android:title="@string/action_settings"/> <item android:id="@+id/main_menu_actionbutton" android:orderInCategory="100" android:showAsAction="always" android:title="@string/Menu"/> </menu>
Remove your onCreateOptionsMenu() and onOptionsItemSelected() methods, along with the menu resource(s) that they use. Then, the overflow should never show up.
The overflow icon is a common UI convention that's leveraged throughout Android to hide settings and other unimportant options. Google is now replacing it in the Play Store with a “tap & hold” gesture and bottom sheet menu.
Fire up the “System UI Tuner” app, and then open the menu at the top left to get started. In the menu, choose the “Status Bar” option. Just like on stock Android, you can run through and enable or disable whatever you like.
If you mean the three dots, that's called the overflow menu. It exists on devices which do not have a hardware menu button - which your Galaxy S3 has, while the Nexus 7 does not. So on your S3 you press the menu button and get the popup at the bottom, but on the Nexus you press the 3 dots and get the overflow popup dropping down from the action bar. If it wasn't there, how would you be able to access overflow items?
If you'd simply like to remove it altogether, just delete the first <item />
entry in the menu.xml
you posted.
There are two methods in your "MainActivity" java class. They are called onCreateOptionsMenu and onOptionsItemSelected. These are usually added by IDEs like Eclipse when you use the default settings to create an Activity in your project. The methods look like the ones shown below.
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.settings, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { return true; } return super.onOptionsItemSelected(item); }
These methods create the menu items and insert code for what is to be done when one of the menu items are clicked. Just remove or comment out these two methods and you should see that the menu button will vanish. The XMLs can still have them just in case you want your menu items or menu back.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With