kinsell
kinsell

Reputation: 358

Hide context menu without disabling text selection

The goal is to show a custom context menu, on top of the selected text. Tried clearing the menu items in onSupportActionModeStarted:

@Override
public void onSupportActionModeStarted(android.support.v7.view.ActionMode mode) {
    super.onSupportActionModeStarted(mode);
    mode.getMenu().clear();
    mode.getMenu().close();

}

but the context menu is still showing with a blank background and back button and with no items inside

I tried setting <item name="windowActionModeOverlay">false</item> to the AppTheme but to no avail.

Is there any way to do this?

Upvotes: 1

Views: 542

Answers (1)

Weverton Peron
Weverton Peron

Reputation: 97

Have you tried this way? @Override public void onActionModeStarted(ActionMode mode) { super.onActionModeStarted(mode); mode.getMenu().clear(); mode.getMenu().close(); }

I have made without support and worked. It have not needed: <item name="windowActionModeOverlay">false</item>

Remember to implement this in one activity.

Upvotes: 1

Related Questions