Display menu in actionmode?

296 Views Asked by At

I have a actionbar (actionbarsherlock) in my activity. At some point it displays a actionmode with a few buttons.

Is it possible to use a actionprovider to provide a menu for one of the buttons in the actionmode?

I tried a simple one:

@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
MenuItem mistyle = menu.add(Menu.NONE, -1, Menu.NONE, "Style").setIcon(R.drawable.ic_menu_settings_holo_light);
mistyle.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);
mistyle.setActionProvider(new StyleActionProvider(context));

But onPrepareSubMenu and hasSubMenu from ActionProvider is not called. (I do return null in onCreateActionView of ActionProvider)

This works without problem when i use actionprovider on a actionbar instead of actionmode. That is why i was wondering if this was supported.

If it is not supported is it in a other way possible to display a menu when the user presses a button in the actionmode bar?

1

There are 1 best solutions below

1
On