October 2018
Intermediate to advanced
464 pages
15h 17m
English
As you saw in step 2, we used the same menu XML to define the contextual menu as the other menus.
The main piece of code to understand is the ActionMode callback. This is where we handle the Contextual Mode events: initializing the menu, handling menu item selections, and cleaning up. We start Contextual Mode in the long press event with a call to startActionMode() by passing in the ActionMode callback created in step 5.
When action mode is triggered, the system calls the onCreateActionMode() callback, which inflates the menu and displays it in the CAB. The user can dismiss the CAB by pressing the back arrow or the back key. The CAB is also dismissed when the user makes a menu selection. We show a Toast to give a visual feedback ...