title: RecyclerView item click checked state
body: <p>I have a horizontal <code>RecyclerView</code>, in which I have a circular <code>ImageView</code>, on item click, I want the selected circle image to get highlighted.</p>
  <p>I use <a href="https://github.com/hdodenhof/CircleImageView" rel="nofollow noreferrer">https://github.com/hdodenhof/CircleImageView</a> for circular <code>ImageView</code></p>
  <p>I tried but am not getting how to disable the highlighted item of another position other than the current position.</p>
  <p>my Adapter code is given below</p>
  <pre><code>public class AddEventIconsAdapter extends RecyclerView.Adapter&lt;AddEventIconsAdapter.NavigationViewHolder&gt; {
  
  private Context context;
  public int mSelectedItem = -1;
  List&lt;ChildSpouseCustomModel&gt; listIcons;
  
  
  public AddEventIconsAdapter(Context context, List&lt;ChildSpouseCustomModel&gt; 
   listIcons) {
      this.context = context;
      this.listIcons = listIcons;
  
  
  }
  
  @Override
  public AddEventIconsAdapter.NavigationViewHolder 
  onCreateViewHolder(ViewGroup parent, int viewType) {
  
    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.list_item_add_icons, parent, false);
      return new AddEventIconsAdapter.NavigationViewHolder(view);
  }
  
  @Override
  public void onBindViewHolder(final AddEventIconsAdapter.NavigationViewHolder holder, final int position) {
  
      Glide.with(context).load(listIcons.get(position).getImgUrl())
              .thumbnail(0.5f)
              .crossFade()
              .error(R.drawable.ic_user_placeholder)
              .diskCacheStrategy(DiskCacheStrategy.ALL)
              .into(holder.img_EventIcon);
      holder.itemView.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
  
              if (mSelectedItem == position) {
                  mSelectedItem=-1;
  
                  holder.img_EventIcon.setBorderWidth(0);
                  holder.img_EventIcon.setBorderColor(context.getResources().getColor(R.color.colorPrimary));
  
              } else {
                  mSelectedItem = position;
                  notifyDataSetChanged();
                  holder.img_EventIcon.setBorderWidth(5);
                  holder.img_EventIcon.setBorderColor(context.getResources().getColor(R.color.colorPrimary));
  
              }
  
          }
      });
  }
  
  @Override
  public int getItemCount() {
      return listIcons.size();
  }
  
  
  class NavigationViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
  
  
      private CircleImageView img_EventIcon;
  
  
      public NavigationViewHolder(View itemView) {
          super(itemView);
          img_EventIcon = (CircleImageView) itemView.findViewById(R.id.profile_image_parent);
  
  
      }
  
      @Override
      public void onClick(View v) {
  
      }
  }
  }
  </code></pre>
  <p>my list item xml is given below</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
  android:layout_width=&quot;wrap_content&quot;
  android:layout_height=&quot;wrap_content&quot;
  android:layout_gravity=&quot;center&quot;
  android:layout_marginLeft=&quot;6dp&quot;
  android:layout_marginRight=&quot;8dp&quot;
  android:gravity=&quot;center&quot;
  android:orientation=&quot;vertical&quot;&gt;
  
  
  &lt;de.hdodenhof.circleimageview.CircleImageView
      android:id=&quot;@+id/profile_image_parent&quot;
      android:layout_width=&quot;52dp&quot;
      android:layout_height=&quot;52dp&quot;
      android:src=&quot;@drawable/ic_user_placeholder&quot; /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  <p>My expected output: one clicked image highlighted at a time</p>
  <p><a href="https://i.stack.imgur.com/p0YWD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p0YWD.png" alt="enter image description here" /></a></p>
  <p>My present Output when I run the above code  :</p>
  <p><a href="https://i.stack.imgur.com/V8tFy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V8tFy.png" alt="enter image description here" /></a></p>
  <p>How can I highlight only the clicked item circle image? is there anyway, can anyone help me to sort it out.</p>