The official page for the Navigation Drawer design pattern states:
Sometimes the user will be in a state where a contextual action bar (CAB) appears instead of the app’s action bar. This typically happens when the user selects text or selects multiple items after a press-and-hold gesture. While the CAB is visible, you should still allow the user to open the navigation drawer using an edge swipe. However, replace the CAB with the standard action bar while the navigation drawer is open. When the user dismisses the drawer, re-display the CAB.
But after researching I can't seem to find a way to "dismiss" the Contextual Action Bar inside my
@Override
public void onDrawerOpened(View drawerView) {
// ... My Code ...
}
method.
In my case a CAB (with copy, paste, etc. options) may appear when a user selects text from an EditText
in an Activity
which itself displays a Nav. Drawer.
I've seen this question+answer but it doesn't quite fix my problem as it's related to a custom ActionMode. How can I "dismiss" the CAB - the one that shows up when a user selects text - whenever the navigation drawer is toggled?
It is possible. You have to grab a reference to the
ActionMode
when it is created, and theActionMode.Callback
in yourActivity
:Then when your drawer opens/closes, finish the
ActionMode
or start a newActionMode
from theActionMode.Callback
: