Android – How to force overflow menu on android actionbar compat

actionbarsherlockandroidandroid-4.0-ice-cream-sandwichandroid-actionbaroverflow

Android action bar compat
Is it possible? On older devices (pre 3.0) the items that don't fit the action bar are only shown when the menu key is pressed, I want these items to be grouped in the actionbar's overflow menu.

Best Answer

The action overflow menu is only available when there is no hard menu button available on the device. I found this stated in the Framework Topics under User Interface > Action Bar, check out the 3rd bullet here.

There is an action bar library written by Jake Wharton called ActionBarSherlock. Perhaps this is able to supply you with an action overflow menu style even when on older devices (which include a hard menu button), however I have not looked into this.

Edit: ActionBarSherlock 4.0 (currently a release candidate) has functionality built in to force action overflow. If you want to extend the ActionBarCompat example yourself, you could take a look on github to get an idea how Jake implemented it. I would suggest just looking into using his library all together, as it is very well done.

If you choose to use Jake's library, look into setting up the Activity theme as @style/Theme.Sherlock.ForceOverflow to force the overflow menu on older devices.

Edit2: Using ForceOverflow theme causes issues (example #1) on devices with hardware menu button. Thus, Jake Wharton is going to remove ForceOverflow in the future versions.