java - ListView displays different items than what is in the holder -
i have custom adapter extends baseadapter. has variety of different layouts thumbnails without. when add new item same type 1 before row displays same values. when check set in holder tells me correct items set.
public view getview(int position, view convertview, viewgroup parent) { int layouttype = getitemviewtype(position); listviewrow item = null; if(convertview == null) { item = atindex(position); holder = new viewholder(); convertview = getconvertview(layouttype, parent);//viewholder items declared here convertview.settag(-1, holder); } else if(!viewmatchestype(layouttype, convertview.getid())){ item = atindex(position); holder = new viewholder(); convertview = getconvertview(layouttype, parent);//viewholder items declared here convertview.settag(-1, holder); } else { holder = (viewholder) convertview.gettag(-1); item = atindex(position); } setdisplay(item, convertview);//i set values here if(holder.tv_name.gettext() != item.getname()) { notifydatasetinvalidated(); } return convertview; } //for performance, ui elements saved in holder private static class viewholder { public imageview iv_thumbnail; public textview tv_name; }
i havent found optimal solution problem myself, removing if condition seems work me. instead of this
if(convertview == null) { item = atindex(position); holder = new viewholder(); convertview = getconvertview(layouttype, parent);//viewholder items declared here convertview.settag(-1, holder); }
just use this
item = atindex(position); holder = new viewholder(); convertview = getconvertview(layouttype, parent);//viewholder items declared here convertview.settag(-1, holder);
it sure heavy on memory, haven't found other solution.
Comments
Post a Comment