title: Viewholder's getAdapterPosition and getLayoutPosition is always -1
body: <p>I have the following <code>AssessmentAdapter</code> class.  In the <code>constructor</code> of my <code>ViewHolder</code> class, I <code>findViewById()</code> to get the <code>ImageView</code> with the delete icon, and assign the click event to it.  </p>
  
  <p>I am trying to find the position of my ViewHolder, and send this to the parameterized constructor of my <code>OnDeleteIconClicked</code> class, but the position is always <code>-1</code>.  Why?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>public class AssessmentAdapter extends RecyclerView.Adapter&lt;AssessmentAdapter.AssessmentViewHolder&gt; {
  
  private List&lt;Assessment&gt; assessmentList;
  private IAssessmentsList context;
  
  public AssessmentAdapter(List&lt;Assessment&gt; assessmentList, IAssessmentsList context){
      this.assessmentList = assessmentList;
      this.context = context;
  }
  
  @Override
  public AssessmentViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View rowView = LayoutInflater.from(parent.getContext())
              .inflate(R.layout.assessment_list_row, parent, false);
  
      rowView.setOnClickListener(new OnAdapterItemClicked());
  
      return new AssessmentViewHolder(rowView);
  }
  
  @Override
  public void onBindViewHolder(AssessmentViewHolder holder, int position) {
      Assessment assessment = assessmentList.get(position);
      holder.txtClientName.setText(assessment.getClient());
      holder.txtAssessmentDate.setText(assessment.getInspectedDate());
      holder.imageView.setTag(assessment.getId());
  }
  
  @Override
  public int getItemCount() {
      return assessmentList.size();
  }
  
  public class AssessmentViewHolder extends RecyclerView.ViewHolder{
  
      public TextView txtClientName, txtAssessmentDate;
      public ImageView imageView;
  
      public AssessmentViewHolder(View view){
          super(view);
  
          txtClientName = view.findViewById(R.id.txtClientName);
          txtAssessmentDate = view.findViewById(R.id.txtAssessmentDate);
  
          imageView= view.findViewById(R.id.deleteAssessment);
          int layoutPosition = getLayoutPosition(); //always -1
          int adapterPosition = getAdapterPosition(); //always -1
          imageView.setOnClickListener(new OnDeleteIconClicked(getAdapterPosition()));
      }
  }
  
  public class OnAdapterItemClicked implements View.OnClickListener{
  
      @Override
      public void onClick(View v) {
          context.OnAdapterItemClicked(v);
      }
  }
  public class OnDeleteIconClicked implements View.OnClickListener {
  
      private int position;
  
      public OnDeleteIconClicked(int position){
          this.position = position;
      }
  
      @Override
      public void onClick(View v) {
          context.OnDeleteItemClicked(Integer.parseInt(v.getTag().toString()), position);
      }
  
      public int getPosition() {
          return position;
      }
      public void setPosition(int position) {
          this.position = position;
      }
  }
  }
  </code></pre>