October 2018
Intermediate to advanced
464 pages
15h 17m
English
If you need to use the old-style context menu, for example to support pre-Android 3.0 devices, it's very similar to the Option Menu API, you just different method names. To create the menu, use onCreateContextMenu() instead of onCreateOptionsMenu(). To handle the menu item selection, use onContextItemSelected() instead of onOptionsItemSelected(). Finally, call registerForContextMenu() to let the system know you want context menu events for the view.
Since Contextual Mode is considered the preferred way to display context options, this recipe will focus on the newer API. Contextual Mode offers the same features as the floating context menu, but also adds additional functionality by allowing multiple item selection ...