In older apps I would typically use onCreateContextMenu()
with the following signature for context actions:
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo)
The menuInfo
would provide me the information for which item in my list the context menu was being built. I could then get the right Uri
to find the actions that are appropriate for it and create them as menu items (using automatic intents or whatever).
Now, with the newer APIs, the replacement for this is the contextual action bar using ActionMode
:
public boolean onCreateActionMode(ActionMode mode, Menu menu)
public boolean onPrepareActionMode(ActionMode mode, Menu menu)
But here, how can I distinguish the item and/or get this position info?
For batch mode, such a parameter not being present, makes sense, because you should only offer actions that are applicable to anything. But for the single mode, wouldn't this be entirely equivalent to the old API, except the buttons are now in the action bar?
Reference: http://developer.android.com/guide/topics/ui/menus.html#context-menu