android - Recycle view getting change while scrolling -
i trying change image in recycleview dynamically. changed when scroll recycleview imageview change
here adapter class code:
public class recyclerviewadapter extends recyclerview.adapter<recyclerviewholders> { private list<itemobject> itemlist; private context context; ongridselected ongridobj; public recyclerviewadapter(context context, list<itemobject> itemlist,ongridselected ongridobj) { this.itemlist = itemlist; this.context = context; this.ongridobj = ongridobj; } @override public recyclerviewholders oncreateviewholder(viewgroup parent, int viewtype) { view layoutview = layoutinflater.from(parent.getcontext()).inflate(r.layout.card_view_list, null); recyclerviewholders rcv = new recyclerviewholders(layoutview,itemlist,ongridobj); return rcv; } @override public void onbindviewholder(recyclerviewholders holder, int position) { if(!itemlist.get(position).isselected()) { holder.countryname.settext(itemlist.get(position).getname()); holder.countryphoto.setimageresource(itemlist.get(position).getphoto()); itemlist.get(position).setisselected(true); } } @override public int getitemcount() { return this.itemlist.size(); } }
how prevent recycle view getting recycle?
please try this:
if using recycyclerview
,override getitemviewtype
method.
@override public int getitemviewtype(int position) { return position; }
Comments
Post a Comment