The official documentation Selection | Android Developers notes that:
Selecting CAB actions
You can decide which actions and elements appear in the CAB. Use the
guidelines in the Action Bar pattern to decide which items to surface
at the top level and which to move to the action overflow.
Dynamically adjust CAB actions
In most cases you need to adjust the actions in the CAB dynamically as
the user adds more items to the selection. Actions that apply to a
single selected data item don't necessarily apply to multiple selected
data items of the same kind.
Unfortunately, the link included in the quote links to a section which also only holds general information without actually going into details. To make things worse, it links back to the Selection | Android Developers page.
Looking a bit further, I found this tutorial from Lars Vogel. I quote (formatting mine):
A contextual action mode activates a temporary ActionBar
that overlays the application ActionBar
for the duration of a particular sub-task.
The contextual action mode is typically activated by selecting an item or by long clicking on it.
To implemented this, call the startActionMode(
) method on a View or on
your activity. This method gets an ActionMode.Callback
object which is
responsible for the lifecycle of the contextual ActionBar
.
You could also assign a context menu to a View
via the
registerForContextMenu(view)
method. A context menu is also activated
if the user "long presses" the view. The onCreateContextMenu()
method
is called every time a context menu is activated as the context menu
is discarded after its usage. You should prefer the contextual action
mode over the usage of context menus.
The most prominent reference mentions that we can create our own menu using registerForContextMenu(view)
. Rather than duplicating an answer, I found this answer by J. Pablo Fernández which contains a code example on how to apply your own CAB. Registering a new context menu should override any default menu but I am not sure. As I am unable to test this at the moment, I would be glad to hear whether this solved your problem.
android-
prefix? – Damnatory