title: How to retrieve the listview selected item in Contextual Action Bar
body: <p>I'm using Contextual Action Barwith ListView (CHOICE MODE SINGLE). Everything works but I don't know how to retrieve the selected item.</p>
  
  <pre><code>listViewData.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
  
  listViewData.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
          @Override
          public boolean onItemLongClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              if (mActionMode != null) {
                  return false;
              }
  
              mActionMode = ((ActionBarActivity) getActivity()).startSupportActionMode(mActionModeCallback);
              view.setSelected(true);
              return true;
          }
  });
  
  private ActionMode.Callback mActionModeCallback = new ActionMode.Callback() {
      @Override
      public boolean onCreateActionMode(ActionMode mode, Menu menu) {
          MenuInflater inflater = mode.getMenuInflater();
          inflater.inflate(R.menu.context_menu, menu);
          return true;
      }
  
      @Override
      public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
          return false;
      }
  
      @Override
      public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
  
          switch (item.getItemId()) {
              case R.id.menu_edit:
                  mode.finish();
                  return true;
              case R.id.menu_share:
                  mode.finish();
                  return true;
              case R.id.menu_delete:
                  mode.finish();
                  return true;
              default:
                  return false;
          }
      }
  
      @Override
      public void onDestroyActionMode(ActionMode mode) {
          mActionMode = null;
      }
  };
  </code></pre>