Enabling Contextual Action Mode for a view
A Context Menu provides additional options related to a specific view—the same concept as a right-click on the desktop. Android currently supports two different approaches: the floating Context Menu and Contextual Mode. Contextual Action Mode was introduced in Android 3.0. The older floating Context Menu could lead to confusion since there was no indication of the currently selected item and it didn't support actions on multiple items—such as selecting multiple emails to delete in one action.
Creating a Floating Context Menu
If you need to use the old style Context Menu, for example, to support preAndroid 3.0 devices, it's very similar to the Option Menu API, 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...