changing imageview’s color in recyclerview?

I am using recyclerview for listify my data, and i have requirement to add any item to user’s favourite list, so i am using a png imageview in adapter’s view, but whenever i click the imageview to add the item in my favourite list, the color of all images changes. but i want to change just the clicked imageview’s color.
here is my code.

 public mViewHolder(View itemView) {
        super(itemView);
        txtViewTitle = (TextView) itemView.findViewById(R.id.txttitle_toptwenty);
        subtitle = (TextView) itemView.findViewById(R.id.sub_title_toptwenty);
        thumbnail = (NetworkImageView) itemView.findViewById(R.id.thumbnail_topwenty);
        frame = (RelativeLayout) itemView.findViewById(R.id.layer);
        brandid = (TextView) itemView.findViewById(R.id.offerid);
        cardview = (CardView) itemView.findViewById(R.id.card_view);
        data=(TextView)itemView.findViewById(R.id.textView24);
         clip=(ImageView)itemView.findViewById(R.id.add_fav);
        Typeface face= Typeface.createFromAsset(AppController.getInstance().getAssets(), "font/trebuc.ttf");
        subtitle.setTypeface(face);
        txtViewTitle.setTypeface(face);
         //ripple=(MaterialRippleLayout)itemView.findViewById(R.id.ripple);

        clip.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Resources res = AppController.getInstance().getResources();
                final Drawable drawable = res.getDrawable(R.drawable.ic_clipped_32);
                drawable.setColorFilter(Color.BLACK, PorterDuff.Mode.SRC_ATOP);
                clip.setBackgroundDrawable(drawable);
                notifyItemChanged(getAdapterPosition());

            }
        });
    }


Source: android

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.