Francesco Ambrosini
Francesco Ambrosini

Reputation: 501

SubMenu showAsAction when added at runtime

I'm adding a SubMenu at runtime and everything works great. I just have a problem: how to set showAsAction="always" on a runtime-added SubMenu? There is no method to achieve that and if don't set it I can't find any way to have it shown in the Action Bar. Thanks for helping

Upvotes: 2

Views: 485

Answers (3)

Rodrigo Daros
Rodrigo Daros

Reputation: 13

Call yourSubMenu.getItem(). This give you MenuItem that represent the SubMenu.

Upvotes: 1

cwhite
cwhite

Reputation: 41

Don't know if this is too late or not, but SubMenu has as function called getItem() which returns a MenuItem. You can then get this MenuItem, and call setShowAsAction() afterwards. Hope this helps!!!

Upvotes: 4

Jerry Wattre
Jerry Wattre

Reputation: 204

If im right then MenuItem = item.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

Upvotes: 0

Related Questions