Ben
Ben

Reputation: 758

Android Action Bar add all icon to overflow

I am updating my apps to have action bars, as Google seems to want developers to do now, and I am trying to get all the options of one app to all be in the overflow menu. I have searched far and wide but I can't seem to find anything that would make them do that. I'm pretty sure it would be something in the xml that defines the menu items. Do any of you guys know how to make all the menu options be in the overflow menu?

Upvotes: 1

Views: 1601

Answers (2)

Edvald Eysteinsson
Edvald Eysteinsson

Reputation: 221

As CommonsWare said, showAsAction is the key. Set android:showAsAction="never" on the if you are inflating an xml or use item.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER); if you are creating the items with code.

You should consider using android:showAsAction="ifRoom" or item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); since the actionbar will contain a lot of empty space, if you don't fill it with something else that is.

Upvotes: 2

CommonsWare
CommonsWare

Reputation: 1007544

They will all be in the overflow menu by default. You have to specifically do things to your menu resource XML files to change that, notably have android:showAsAction attributes on the <item> elements.

Upvotes: 1

Related Questions