Search code examples
androidactionbarsherlockandroid-actionbar

ActionBarSherlock collapseActionView


I'm having a problem when I try to set one item in my actionbar as always visible and 4 more icons as dropdown items with the following layout:

 <?xml version="1.0" encoding="utf-8"?>
 <menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:id="@+id/search_movies"
        android:icon="@drawable/action_search"
        android:showAsAction="always"
        android:title="Search"/>
    <item
        android:id="@+id/movies"
        android:icon="@drawable/action_video"
        android:showAsAction="collapseActionView"
        android:title="Movies"/>
    <item
        android:id="@+id/theaters"
        android:icon="@drawable/action_location_map"
        android:showAsAction="collapseActionView"
        android:title="Theaters"/>
    <item
        android:id="@+id/preferences"
        android:icon="@drawable/action_settings"
        android:showAsAction="collapseActionView"
        android:title="Preferences"/>
    <item
        android:id="@+id/contact"
        android:icon="@drawable/action_about"
        android:showAsAction="collapseActionView"
        android:title="Contact"/>

    </menu> 

The result is just the first item showing and the rest are not visible, not even as a dropdown. This is using ActionBarSherlock and a 2.3 Android device.

The question is, how can I get the icons to follow this layout:

enter image description here

EDIT:

The problem I had was because when you are using the actionbar with a device that has a "menu" hardware button the 3-dot dropdown does not shows off, the 4 other items are only displayed if you press the menu hardware button. Does anyone knows if this behaviour can be modified?


Solution

  • Hmmm, maybe I misunderstood, but if you wish to places those remaining four items into the overflow action menu (the 3-dot icon) then using android:showAsAction="never" instead of "collapseActionView" should do it.

    ...Tried a couple ways, but this did the trick: Force overflow menu in ABS