ActionbarSherlock does not include “overflow” section of Action Bar (on Android 2.1)

橙三吉。 提交于 2019-12-21 05:04:24

问题


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 )


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/9276385/actionbarsherlock-does-not-include-overflow-section-of-action-bar-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!