title: Set background color programmatically on RecyclerView item (certain element in item)
body: <p>I have <code>ActivityGame</code> which has <code>TextView</code> that contains a par number. In that same <code>Activity</code> I have a <code>RecyclerView</code> and that <code>RecyclerView</code>, of course, contains multiple items. Those items have different par numbers.</p>
  
  <p>For example, the Par number in <code>ActivityGame</code> is 3, now in <code>RecyclerView</code> items, let's say I have 1 item which has par number of 3, second has 2 and third has 4.</p>
  
  <p>If an item's par number is the same as <code>ActivityGame</code>'s par number, then that items par numbers background should turn to grey. If item's par number is more than par number in the <code>ActivityGame</code>, then item's par number background should change to purple. And finally, if its smaller than <code>ActivityGame</code>'s par number, the item's par number background should change to blue.</p>
  
  <p>Here is something I tried to do in the adapter, in order to make this work:</p>
  
  <pre><code>@Override
  public void onBindViewHolder(@NonNull GameViewHolder holder, int position) {
      holder.mTextPar.setText(currentItem.getText2());
  
      /** If persons par number is smaller than course par number, then change persons par number background to blue **/
      if (Integer.parseInt(holder.mTextPar.getText().toString()) &lt; Integer.parseInt(ActivityGame.mHoleNm.getText().toString())) {
          holder.mTextPar.setBackgroundColor(Color.parseColor("#255eba"));
          notifyDataSetChanged();
      }
  }
  </code></pre>
  
  <p>This is what I thought would work, but it didn't, when I try to open <code>ActivityGame</code> where all this happens, my app crashes instantly.</p>
  
  <p>I assume that <code>onBindViewHolder</code> is the correct place to make this happen, but I obviously have a wrong method. If you have a better idea where or how should I handle this, please share it. Thanks in advance.</p>