I have an ActionBar that should display the action buttons in a custom way. For this I created a custom view and attached it to the ActionBar.
One thing to mention is that I am using a menu.xml resoure file to load the options menu and display them on a smartphone, but do not display them on tablet, instead use a custom view. For this I market every menu item in the xml as: android:showAsAction="never"
Everything looks fine, except one little thing that still remains on the right of the ActionBar - the "More" button.
How can I remove it?

I tried this:
ActionBar bar = activity.getActionBar();
bar.removeAllTabs();
but the "more" button still remains there.
EDIT:
This is my menu.xml file:
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:id="@+id/menu_username"
android:icon="@drawable/menu_username"
android:orderInCategory="0"
android:showAsAction="never"
android:title="@string/menu_username">
<menu>
<item
android:id="@+id/menu_logout"
android:title="@string/menu_logout"/>
</menu>
</item>
<item
android:id="@+id/menu_settings"
android:icon="@drawable/menu_settings"
android:orderInCategory="1"
android:showAsAction="never"
android:title="@string/menu_settings"/>
<item
android:id="@+id/menu_search"
android:icon="@drawable/menu_search"
android:orderInCategory="1"
android:showAsAction="never"
android:title="@string/menu_search"/>
</menu>
Please note I still want to inflate this menu on a smartphone, but don't want to use it on a tablet.
Setting showAsAction="never" will force an menu item into the overflow. Why not check in onCreateOptionsMenu(...) that the device is a tablet, and if it is just not inflate the menu? Something like this:
public boolean onCreateOptionsMenu(Menu menu) {
if (getResources().getConfiguration().smallestScreenWidthDp >= 600) {
//It's a tablet, don't inflate, only create the manual view
manualMenuCreation();
} else {
getMenuInflater().inflate(R.menu.menu, menu);
}
return true;
}
Don't forget smallestScreenWidthDp is only available in 3.2 or above, so you'll have to take that into consideration.
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