If I define the following items for my action bar:
res/menu/action_menu.xml
:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:title="label"/>
<item android:title="label1"/>
<item android:title="label2"/>
<item android:title="label3"/>
<item android:title="label4"/>
</menu>
In my Activity:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.action_menu, menu);
return true;
}
Is there anyway to allow me define certain items move to action overflow part ? and how to do it?
P.S. Action overflow part is the right-most part of action bar which hide certain items like a popup menu.
It's the other way round. You need to explicitly tell the menu which ones you want in the ActionBar
and which not by setting the appropriate flags
E.g.
<item android:id="@+id/refresh"
android:title="@string/refresh"
android:icon="@drawable/reload_button"
android:showAsAction="always"/>
Here android:showAsAction
tells how to handle it. Options are
You can or options together with the pipe symbol as "always|withText"
See the android docs for action bar for more documentation.
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