Search code examples
androidandroid-3.0-honeycombcontextual-action-bar

How to invoke the ActionBar's ContextMenu-like behavior?


In Android 3.0, when you select some text for example, the ActionBar switches to a ContextMenu-like mode, which enables you to do actions with the selected text: copy/share/etc, and a "Done" button appears on the left side to enable the user to leave this mode.

How can I switch the ActionBar into this mode in my app (with my menu items of course)? I just couldn't find this in the docs.


Solution

  • Yeah, I couldn't find it either -- I had to ask at Google I|O.

    Use startActionMode(). Here is one of their samples that demonstrates it. I need to do more work in this area myself.