Change background of RecyclerView selected item
<p>I have a recylcerView, I want to change the background color of selected textview, if user clicks on next textview previous selection should be removed, and current should be highlighted, so far what I have done is that it highlights selected date and keeps previous one highlighted</p>

<pre><code>    public void onBindViewHolder(final DateHolder holder, final int position) {
        final String monthDate = arrayListDate.get(position);
        final GradientDrawable gd = new GradientDrawable();
        gd.setShape(GradientDrawable.OVAL);
        final GradientDrawable drawable=new GradientDrawable();
        drawable.setShape(GradientDrawable.OVAL);
        if(selectedDate.contains(monthDate)){

            if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.JELLY_BEAN) {
                drawable.setColor(Color.parseColor("#006EB9"));
                drawable.setSize(width,height);
                holder.tvDate.setTextColor(getResources().getColor(R.color.white));
                holder.tvDate.setBackground(drawable);                
             }
        }
            ViewTreeObserver viewTreeObserver = relativeLayout.getViewTreeObserver();
            viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
                @Override
                public void onGlobalLayout() {
                    if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.JELLY_BEAN) {                            holder.tvDate.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                        width = holder.tvDate.getMeasuredWidth();
                        height = holder.tvDate.getLineHeight();
                    } else {
                        //noinspection deprecation
                        holder.tvDate.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                        width = holder.tvDate.getMeasuredWidth();
                        height= holder.tvDate.getLineHeight();
                    }

                }
            });

                holder.tvDate.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        selectedDate.clear();
                        selectedDate.add(monthDate);
                        notifyItemChanged(position);

                    }
                });
        }
</code></pre>