Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is a late answer, but I think would help people stuck. </p> <p>Opening the contextual action bar is actually pretty simple, at any point in your activity you just have to call:</p> <pre><code>startActionMode(mActionModeCallback); </code></pre> <p>If you are not in your main activity, like in fragments, you can get a reference with </p> <pre><code>getSherlockActivity().startActionMode(mActionModeCallback); </code></pre> <p>and this is the callback</p> <pre><code>private ActionMode.Callback mActionModeCallback = new ActionMode.Callback(){ @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.actionbar_context_menu, menu); return true; } @Override public void onDestroyActionMode(ActionMode mode) { } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { switch (item.getItemId()) { case R.id.menu_item1: return true; case R.id.menu_item2: //close the action mode //mode.finish(); return true; default: mode.finish(); return false; } } }; </code></pre> <p>The xml is a simple menu like the actionbar one:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;item android:id="@+id/menu_item1" android:icon="@drawable/ic_item1" android:title="@string/ITEM1" android:showAsAction="always|withText" /&gt; &lt;item android:id="@+id/menu_item2" android:icon="@drawable/ic_item2" android:title="@string/ITEM2" android:showAsAction="always|withText" /&gt; </code></pre> <p></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload