title: RecyclerView onItemClicked callback
body: <p>I am implementing a Navigation Drawer with a RecyclerView, using <a href="http://enoent.fr/blog/2015/01/18/recyclerview-basics/" rel="noreferrer">this</a> tutorial, but I don't want to apply the whole tutorial, I just want to handle the user's click. I've implemented the <code>onClickListener</code> inside the <code>ViewHolder</code> of my <code>MyAdapter</code> class:</p>
  
  <pre><code>public static class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener{
      int Holderid; ImageView imageView, profile;
      TextView textView, Name, email, drawerTitle;
  
      private ClickListener listener;
      // ViewHolder Constructor with View and viewType as a parameter
      public ViewHolder(View itemView, int ViewType, ClickListener listener) {
          super(itemView);
  
          if (ViewType == TYPE_HEADER){
              itemView.setClickable(false);
              Name = (TextView) itemView.findViewById(R.id.user_name);
              email = (TextView) itemView.findViewById(R.id.user_email);
              profile = (ImageView) itemView.findViewById(R.id.circleView);
  
              Holderid = 0;
          }
          if(ViewType == TYPE_ITEM) {
              itemView.setClickable(true);
              textView = (TextView) itemView.findViewById(R.id.rowText);
  
              imageView = (ImageView) itemView.findViewById(R.id.rowIcon);
  
              Holderid = 1;
  
              // Handle item click and set the selection
          }
          if(ViewType == TYPE_SEPARATOR){
              itemView.setClickable(false);
              drawerTitle = (TextView) itemView.findViewById(R.id.drawerTitle);
  
              Holderid = 2;
          }
          this.listener = listener;
          itemView.setOnClickListener(this);
          itemView.setOnLongClickListener(this);
      }
      int pos;
      @Override
      public void onClick(View v) {
          if (listener != null) {
              listener.onItemClicked(getPosition());
              pos= getPosition();
              Log.d("TAG", "Item clicked at position " + getPosition());
          }
      }
  
      @Override
      public boolean onLongClick(View v) {
          if (listener != null) {
              return listener.onItemLongClicked(getPosition());
          }
  
          return false;
      }
      public interface ClickListener {
          public void onItemClicked(int position);
          public boolean onItemLongClicked(int position);
      }
  }
  </code></pre>
  
  <p>What I can't understand is how to apply a <code>ClickListener</code> to the <code>MyAdapter</code> object:</p>
  
  <pre><code>        mAdapter = new MyAdapter(dataList, mSelectedPositions, ...?);
  </code></pre>
  
  <p>so that when the user clicks on one item, I can handle the user's click back on the <code>MainActivity</code>.</p>
  
  <p>I've created the Adapter this way (as outlined in the tutorial): </p>
  
  <p>Whole <code>MyAdapter</code> class: <a href="http://pastie.org/private/cibcsj3zieorlkcgh2rm1g" rel="noreferrer">http://pastie.org/private/cibcsj3zieorlkcgh2rm1g</a></p>
  
  <p>and this is my MainActivity class' <code>onCreate</code>:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      /* Assigning the toolbar object ot the view
      and setting the the Action bar to our toolbar */
      toolbar = (Toolbar) findViewById(R.id.tool_bar);
      setSupportActionBar(toolbar);
      // enable ActionBar app icon to behave as action to toggle nav drawer
      getSupportActionBar().setDisplayHomeAsUpEnabled(true); //pulsante drawer
      getSupportActionBar().setHomeButtonEnabled(true);      //pulsante dietro
  
      //Initializing
      mTitle = mDrawerTitle = getTitle();
      SharedPreferences usrData = getSharedPreferences(
                                      usr_loggedin,
                                      MODE_PRIVATE);
      AVATARresID = R.mipmap.aka;
  
      // Add Drawer Item to dataList
      dataList = new ArrayList&lt;&gt;();
      dataList = prepareDatalist(dataList, NAME, EMAIL, AVATARresID);
  
      mRecyclerView = (RecyclerView) findViewById(R.id.RecyclerView);
      mRecyclerView.setHasFixedSize(true);
      mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
  
      mAdapter = new MyAdapter(dataList, mSelectedPositions); //**ERROR HERE**
  
      mRecyclerView.setAdapter(mAdapter);
      mLayoutManager = new LinearLayoutManager(this);
  
      mRecyclerView.setLayoutManager(mLayoutManager);
  
      // Drawer Listener set to the Drawer toggle
      mDrawerLayout.setDrawerListener(mDrawerToggle);
      mDrawerToggle.syncState(); // Finally we set the drawer toggle sync State
  }
  </code></pre>
  
  <p>How do I pull the result of the <code>onClick</code> that is present in the <code>MyAdapter</code> class back to my <code>MainActivity</code>,</p>
  
  <pre><code>    int pos;
      @Override
      public void onClick(View v) {
          if (listener != null) {
              listener.onItemClicked(getPosition());
              pos= getPosition();
              Log.d("TAG", "Item clicked at position " + getPosition());
          }
      }
  </code></pre>
  
  <p>so that I can handle actions depending on the clicked item position?</p>