Note that there are some explanatory texts on larger screens.

plurals
  1. POstartActionMode returning null
    text
    copied!<p>It is really weird. The first time I start the application in eclipse and i call startActionMode, everything works fine. If i close the app and open it again, the startActionMode returns null. It will always return null until I change something in the app and run it again from eclipse. In the documentation, it says that the startActionMode returns null if it was canceled, but it doesn't explain why it is canceled.</p> <p>Any ideas? btw, i`m using actionbarsherlock</p> <p><strong>UPDATE:</strong> if I shutdown my phone or kill the app and start the app again, it works... but then does the same thing when i close it and open it again.</p> <p>here's my code: the ActionModeCallback class:</p> <pre><code> class ActionModeCallback implements ActionMode.Callback{ @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.contextactiondownloads, menu); return true; } @Override public void onDestroyActionMode(ActionMode mode) { } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { // TODO Auto-generated method stub return false; } }; </code></pre> <p>In my mainactivity:</p> <pre><code>public ActionMode startActionMode() { mActionMode = startActionMode(new ActionModeCallback()); return mActionMode; } </code></pre> <p>In my listview adapter:</p> <pre><code> public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { MainActivity activity = (MainActivity)rowView.getContext(); if (isChecked) { if(actionmode == null){ actionmode = activity.startActionMode(); }else { actionmode.invalidate(); } } else { activity.finishActionMode(); actionmode=null; } } }); </code></pre>
 

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