java - Update Specific item in recyclerview -


i have recyclerview , adapter

public class adaptertoupdateok extends recyclerview.adapter<adaptertoupdateok.versionviewholder> { string[] desc; context context; layoutinflater inflater;  adaptertoupdateok adapter;  public adaptertoupdateok(context context,string [] desc) {     this.context = context;     this.desc= desc;     inflater = layoutinflater.from(context); }  @override public versionviewholder oncreateviewholder(viewgroup viewgroup, int i) {     view view = inflater.inflate(r.layout.inflater_sugessted_friends, viewgroup, false);     return new versionviewholder(view); }  @override public void onbindviewholder(final versionviewholder versionviewholder, final int i) {     final versionviewholder v = versionviewholder;     versionviewholder.button.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view view) {             versionviewholder.imageview.setimageresource(r.drawable.ic_ok);         }     });  }  @override public int getitemcount() {     return desc.length; }  class versionviewholder extends recyclerview.viewholder {     button button;     imageview imageview;;     public versionviewholder(final view itemview) {         super(itemview);         button= itemview.findviewbyid(r.id.button);         imageview = itemview.findviewbyid(r.id.imageview);     }  } 

}

current work affect other unclicked parts

use code in viewholder constructor:

public viewholder(view view){ button = (button) view.findviewbyid(r.id.yourbuttonid);  button.setonclicklistener(new view.onclicklistener() {             @override             public void onclick(view view) {                img.setimageresource(r.drawable.ic_ok);              }         });  } 

Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -