title: Contextual actionbar with listview, setselected not working
body: <p>I'm trying to make a contextual <code>ActionBar</code>. I used the sample from the android devpage, but i still haven't got it to work. I set an eventlistener on onitemlongclick, but the <code>setSelected(true)</code> doesn't seem to do anything. I know that the event is triggered, because the <code>actionmode</code> is opened, but it doensn't select any item.</p>
  
  <p>The <code>longclicklistener</code> is in a <code>fragment</code>, held by a <code>viewpager</code> in an activity, which holds several instances of the <code>fragment</code>. I would like to be able to select items from the pages and then do something with the selections.</p>
  
  <p>My current code:</p>
  
  <p>The fragment:</p>
  
  <pre><code>AdapterView.OnItemLongClickListener onLongClick = new AdapterView.OnItemLongClickListener() {
      // Called when the user long-clicks on someView
      @Override
      public boolean onItemLongClick(AdapterView&lt;?&gt; adapterView, View view,
              int i, long l) {
          MainActivity parent = (MainActivity)getActivity();
          if (parent.actionMode != null) {
              return false;
          }
  
          parent.actionMode = getActivity().startActionMode(parent.actionModeCallback);
          view.setSelected(true);
          return true;
      }
  };
  </code></pre>
  
  <p>The action mode callback in the activity</p>
  
  <pre><code>public ActionMode.Callback actionModeCallback = new ActionMode.Callback() {
  
      // Called when the action mode is created; startActionMode() was called
      @Override
      public boolean onCreateActionMode(ActionMode mode, Menu menu) {
          // Inflate a menu resource providing context menu items
          MenuInflater inflater = mode.getMenuInflater();
          inflater.inflate(R.menu.contextual_actionbar, menu);
          return true;
      }
  
      // Called each time the action mode is shown. Always called after onCreateActionMode, but
      // may be called multiple times if the mode is invalidated.
      @Override
      public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
          return false; // Return false if nothing is done
      }
  
      // Called when the user selects a contextual menu item
      @Override
      public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
          switch (item.getItemId()) {
              case R.id.menu_remove_list:
                  mode.finish(); // Action picked, so close the CAB
                  return true;
              default:
                  return false;
          }
      }
  
      // Called when the user exits the action mode
      @Override
      public void onDestroyActionMode(ActionMode mode) {
          actionMode = null;
      }
  };
  </code></pre>