android - Handling ListView recycle (duplicate on scroll) -


i have listview dynamically added images. when user scrolls down list, rows duplicates , shows wrong items + losing layoutparams setting. how can solve problem?

here getview code:

public view getview(int position, view view, viewgroup parent) {     view rowview = view;     viewholder viewholder = new viewholder();     if (rowview == null) {         layoutinflater inflater = ctx.getlayoutinflater();         rowview = inflater.inflate(r.layout.list_row, null, true);         viewholder.linearlayout = (linearlayout) rowview.findviewbyid(r.id.ll_row);         viewholder.textview = (textview) rowview.findviewbyid(r.id.textview_row);         rowview.settag(viewholder);     } else {         viewholder = (viewholder)rowview.gettag();     }     imageresourseid = new arraylist<>(arrays.aslist(convertstringtoarray(imagenames.get(position))));     (int = 0; < imageresourseid.size(); i++) {         linearlayout.layoutparams param = new linearlayout.layoutparams(                 0,                 viewgroup.layoutparams.wrap_content, 0.14f);         imageview imageview = new imageview(ctx);         //imageview.setscaletype(imageview.scaletype.fit_xy);         imageview.setlayoutparams(param);         imageview.setimageresource(ctx.getresources().getidentifier(imageresourseid.get(i), "drawable", ctx.getpackagename()));         viewholder.linearlayout.addview(imageview);     }     viewholder.linearlayout.settag("images");     viewholder.textview.settext(textarray.get(position));     return rowview; } 

this based on how views recycled , inflated. first thing should set image's source null , set image wish. it's bit here , can't recall specifics.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -