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

How to close an ActionMode menu programmatically on Honeycomb?


In my application there is a ListFragment where each item from the list contains a checkbox. Whenever the user clicks on one of those checkboxes the app starts an ActionMode context menu. But I want the application to close the ActionMode menu when clicking on another component. I tried Fragment#closeContextMenu() without success.

Any ideas how can I accomplish that?


Solution

  • Whenever you are creating/starting ActionMode Create by

    mMode = startActionMode(....);
    

    To Dismiss it use following Syntax

    if (mMode != null) 
     {
         mMode.finish();
     }