title: RecyclerView Item Click Listener the Right Way
body: <p>I use <code>RecyclerView</code> adapter to display data inside an activity, I want to implement <code>onClickListener</code> inside the activity, currently, I am setting <code>onClickListener</code> inside adapter as usual which works fine.</p>
  
  <pre><code>public void onBindViewHolder(MyHolder holder, final int position) {
      final Listdata data = listdata.get(position);
      holder.vname.setText(data.getName());
  
      holder.vname.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              Toast.makeText(activity, "clicked on " +position, Toast.LENGTH_SHORT).show();
          }
      });
  }
  </code></pre>
  
  <p>However I want to implement it inside activity so I have greater control. This doesn't serve my purpose. I think it'll be useful for a lot of us. </p>