I am developing Android 2.1 API 7 app. To implement action bar, I am using ActionbarSherlock library.
Everything goes fine with the sherlock library, I can implement action bar with it in my project with the following code.
res/menu/action_menu.xml :
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/new_payment_1"
android:title="@string/new_payment"
/>
<item
android:id="@+id/label_1"
android:icon="@drawable/ic_launcher"
android:showAsAction="always"/>
<item
android:id="@+id/label_2"
android:title="text2"
android:showAsAction="always"/>
<!-- overflow section of action bar -->
<item android:title="title2"/>
<item android:title="title3"/>
<item android:title="title4"/>
</menu>
In my Activity class:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.action_menu, menu);
return true;
}
I got action bar successfully with above code. No problem at all on Android 3.2 platform.
BUT the problem is if I run my app on Android 2.1 platform, the action bar has no overflow section on the Action Bar. Why??? Anyone has experienced the same problem when using Sherlock library on old Android platform??
(P.S. "overflow section" of action bar is the right-most part of action bar which hides some items like a popup menu. More info here )
It uses the native options menu as overflow, just as an Ice Cream Sandwich phone would should one be made with a hardware menu key.
Forcing an overflow action item to be on the action bar on pre-4.0 devices will be a feature of version 4 of ActionBarSherlock.
Support for overflow menu for pre-Ice Cream Sandwich devices has been removed from ActionBarSherlock. A good discussion of this can be found here: Force overflow menu in ActionBarSherlock