title: Why are highlighted items lost after scrolling in recylerview android
body: <p>I want to highlight the item when the action mode is active in the adapter class. I am able to do so but the highlight state is gone after scrolling. I have tried various solutions but I don't know understand why this is happening?</p>
  <pre><code>public class MyAdapter extends RecyclerView.Adapter&lt;MyAdapter.MyViewHolder&gt;  {
  
     
      class MyViewHolder extends RecyclerView.ViewHolder {
   
       
       public void bind(Items viewHolder_item) {     
  
         
              itemView.setOnLongClickListener(new View.OnLongClickListener() {
              @Override
              public boolean onLongClick(View v) {
                  isSelectMode = true;
                  if (viewHolder_item.getIsSelect()){
                      
                      itemView.setBackgroundColor(Color.TRANSPARENT);
                      item.get(position).setSelect(false);
                      selectedList.remove(item.get(position));
                  } else {
                      itemView.setBackgroundColor(Color.GRAY);
                      item.get(position).setSelect(true);
                      selectedList.add(item.get(position));
                  }
                  if (selectList.size() == 0){
                      isSelectMode = false;
                  }
                  return true;
              }
          });
          itemView.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  if (isSelectMode){
                      if (viewHolder_item.getIsSelect()){
                          itemView.setBackgroundColor(Color.TRANSPARENT);
                          item.get(position).setSelect(false);
                          selectedList.remove(item.get(position));
                      } else {
                                                    
                         itemView.setBackgroundColor(Color.GRAY);
                         item.get(position).setSelect(true);   
                         selectedList.add(item.get(position));                      
                      }
                      if (selectList.size() == 0){
                          isSelectMode = false;
                      }
                  }
              }
          });
  }
  </code></pre>
  <p>No matter which solution is implemented, the result is always the same. The highlighted color is gone after scrolling. Any help would be appreciated Thanks.</p>