title: Why is adding an OnClickListener inside onBindViewHolder of a RecyclerView.Adapter considered bad practice?
body: <p>I have the following code for a <code>RecyclerView.Adapter</code> class and it works fine:</p>
  
  <pre><code>public class MyAdapter extends RecyclerView.Adapter&lt;MyAdapter.Viewholder&gt; {
  
      private List&lt;Information&gt; items;
      private int itemLayout;
  
      public MyAdapter(List&lt;Information&gt; items, int itemLayout){
          this.items = items;
          this.itemLayout = itemLayout;
      }
  
      @Override
      public Viewholder onCreateViewHolder(ViewGroup parent, int viewType) {
          View v = LayoutInflater.from(parent.getContext()).inflate(itemLayout, parent, false);
          return new Viewholder(v);
      }
  
      @Override
      public void onBindViewHolder(Viewholder holder, final int position) {
          Information item = items.get(position);
          holder.textView1.setText(item.Title);
          holder.textView2.setText(item.Date);
  
          holder.itemView.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  Toast.makeText(view.getContext(), "Recycle Click" + position, Toast.LENGTH_SHORT).show();
              }
          });
  
         holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
         @Override
         public boolean onLongClick(View v) {
            Toast.makeText(v.getContext(), "Recycle Click" + position, Toast.LENGTH_SHORT).show();
             return true;
         }
  });
      }
  
      @Override
      public int getItemCount() {
          return items.size();
      }
  
      public class Viewholder extends RecyclerView.ViewHolder {
          public  TextView textView1;
          public TextView textView2;
  
          public Viewholder(View itemView) {
              super(itemView);
              textView1=(TextView) itemView.findViewById(R.id.text1);
              textView2 = (TextView) itemView.findViewById(R.id.date_row);
  
          }
      }
  }
  </code></pre>
  
  <p>However, I believe it is bad practice to implement the OnClickListener in the <code>onBindViewHolder</code> method. Why is this bad practice, and what is a better alternative?</p>