I have an action bar in my app with 3 items.
Only 2 can be displayed due to space issues, so I'd expect the first to be displayed and the rest to be displayed in the overflow. However in practice only the first 2 items are shown and there is no overflow detectable.
Here is the relevant code: list_menu.xml
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/menu_insert"
android:icon="@android:drawable/ic_menu_add"
android:title="@string/menu_insert"
android:showAsAction="ifRoom|withText"/>
<item android:id="@+id/menu_call"
android:icon="@android:drawable/ic_menu_call"
android:title="@string/menu_call"
android:showAsAction="ifRoom|withText"/>
<item android:id="@+id/menu_agenda"
android:icon="@android:drawable/ic_menu_agenda"
android:title="@string/menu_agenda"
android:showAsAction="ifRoom|withText"/>
</menu>
Activity.java
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater mi = getMenuInflater();
mi.inflate(R.menu.list_menu, menu);
return true;
}
When you say "overflow" menu, do you mean the three dots that show up in the end to indicate that there are more items.... or do you mean the split actionbar that shows up in the bottom for overflow items?
If you mean the split action bar, you should add this to your activity's manifest file
By default, the three dots overflow menu should happen automatically, so it's hard to tell what the problem is from the information you provided above.
res/menu/menu.xml
MainActivity.java
Download the Action Bar Icon Set
I realize this is not an overflow menu, but it is similar. Okay, this is simple but was hard to figure out.
You first need a menu item you want to use as the overflow inflater. Example
Once you have your item, add a sub-menu containing your items you want in the overflow menu. Example:
On click this will inflate other items within. My application is using ActionBarSherlock 4.0 so before this will work for you, you will need to access the "SplitActionBar". (Will still work on default android Actionbar)
Here's how: In your AndroidManifest.xml file, you need to add this code under the activity you need the overflow menu in.
NOTE: Your item that inflates your overflow menu MUST
showAsAction="always"
Vwola! you have an overflow menu! Hope I helped you out. :)
Try changing the theme of the app from Theme.AppCompat.Light.DarkActionBar to Theme.AppCompat.Light
On devices with hardware menu buttons (Galaxy S3, stubborn as Samsung is...) the overflow menu behaves as the 'traditional' menu, by using the hardware menu button.
To alway show action overflow (three dot) on actionbarcompat:
in menu file, example:
main.xml
and in activity file:
It's worked fine for me.
Tested on Google Nexus S, Samsung S3.