title: This is correct when using onClick in onBindViewHolder to avoid "do not treat position as fixed only use immediately and call holder"?
body: <p>I am working on an application that on the main screen uses RecyclerView to show attendance information of different groups of people, each element contains a list of the last 3 saved records (&quot;Latest records&quot; in the image):</p>
  <p><a href="https://i.stack.imgur.com/6YZfS.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6YZfS.jpg" alt="enter image description here" /></a></p>
  <p>Clicking the &quot;Watch&quot; button should display the attendance record for the corresponding date...</p>
  <p>It turns out that sometimes there are only one or 2 attendance records, so I have to check the size of the list to assign the onClickListener of each element.</p>
  <p>So if there are 3 or more items to display, you would have to add the code for the click events for date 1, date 2 and date 3.
  In the event that there are 2 elements, it would only be for date 2 and date 3.
  Lastly if there is only 1 element, I would add click event for date 3 only.</p>
  <p>As you can imagine, there would be a lot of repeated code, so I decided to add the code for each date in different functions.</p>
  <p>So here my question starts because commonly when I put the code for a click event in <code>onBindViewHolder</code> and use the <code>position</code> variable, it regularly shows me the warning &quot;do not treat position as fixed only use immediately and call holder&quot;. I understand the problem but I realized that when I pass the <code>position</code> variable as a parameter to my click functions it doesn't show me any warning, I guess it's because Android Studio doesn't know that there is a <code>setOnClickListener</code> inside the functions.</p>
  <p>So, these are the parameters that my function was using: <code>private void clcikDate1(TextView tvRecord1, int position, long idGroup, String date){</code> in this approach <code>position</code> was obtained from <code>onBindViewHolder</code> using <code>holder.getAdapterPosition()</code> I know this is wrong and now I show you the current approach:</p>
  <pre><code>@Override
  public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
      Group group = (Grupo) mGroups.get(position);
      .
      .
      .
      .
      .
      long idGroup = group.getId;
      List&lt;AttendanceRecord&gt; recordList = interfaceDB.getLast3Records(idGroup);
      if (recordList.size() == 3){
          //Visual elements code....
          clcikDate1(holder, date1);
          clcikDate2(holder, date2);
          clcikDate3(holder, date3);
      } else if (recordList.size() == 2){
          //Visual elements code....
          clcikDate2(holder, date2);
          clcikDate3(holder, date3);
      } else {
          //Visual elements code....
          clcikDate3(holder, date3);
      }
  }
  
  private void clcikDate1(ViewHolder holder, String date){
      int lastPosition = holder.getAdapterPosition();
      long idGroup = mGroups.get(lastPosition).getId();
      holder.tvRecord1.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View view) {
              clicssListener.seeRecord1Click(lastPosition, idGroup, date);
          }
      });
  }
  </code></pre>
  <p>As you can see now I pass the <code>ViewHolder</code> as a parameter and inside the function I get the <code>TextView</code> and the last position, my question is, is this correct? and another question would be: Is it necessary to get the <code>idGroup</code> variable again in the click function? because as you can see I have one in <code>onBindViewHolder</code> but I don't know if it is necessary to update in my click function</p>