Search code examples
androidactionbarsherlock

ActionBarSherlock - Show overflowed action items as icon + text


Context

I am creating an action bar with some action items, using ActionbarSherlock. Some of them are overflowed, so they are shown in the overflow submenu.

My problem

Those overflowed items are shown in the submenu just as mere texts.

I have tried MenuItem.SHOW_AS_ACTION_IF_ROOM and MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT for setShowAsAction() but both have the same behavior:

Overflowed items without icon

What I want

Is it possible to show these items in the overflow submenu as <their_icon> + <their_text>? Something like this:

Overflowed items with icon


Solution

  • I don't understand either why submenus can have icons and menus only text. Maybe adding menu items as submenus to the root menu could help you. :)

    Just a mention, adding icons like this will force you to use the ActionBar (Sherlock) and not the standard way of displaying menus at the bottom when pressing the menu key in older versions of Android.

    <menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:id="@+id/root_menu"
        android:icon="@drawable/ic_menu_moreoverflow_normal_holo_light"
        android:showAsAction="always"
        android:title="More">
        <menu>
            <item
                android:id="@+id/menu_settings"
                android:icon="@drawable/ic_menu_settings_holo_light"
                android:showAsAction="never"
                android:title="Settings" />
            <item
                android:id="@+id/menu_about"
                android:icon="@drawable/ic_menu_info_details"
                android:showAsAction="never"
                android:title="About"/>
       </menu>
    </item>
    </menu>