Android: My GridView's photos is mixed -
public class imageadapter extends baseadapter { layoutinflater inflater; imageview photo; checkbox check; bitmapfactory.options options; public imageadapter(context c) { inflater = (layoutinflater)c.getsystemservice(context.layout_inflater_service); } public int getcount() { return receivedphoto.size(); } public object getitem(int position) { return receivedphoto.get(position); } public long getitemid(int position) { return position; } public view getview(int position, view convertview, viewgroup parent) { if(convertview == null) { convertview = inflater.inflate(r.layout.phototab_list, parent, false); photo = (imageview)convertview.findviewbyid(r.id.photos); check = (checkbox)convertview.findviewbyid(r.id.photoscheck); options = new bitmapfactory.options(); options.insamplesize = 16; } log.i("load", position + ""); if(receivephotos.get(position) == null) { receivephotos.set(position, bitmapfactory.decodefile((string)(receivedphoto.get(position)), options)); } photo.setimagebitmap(receivephotos.get(position)); int check = photoischeck.get(position); if(check == 0) { check.setchecked(false); } else { check.setchecked(true); } return convertview; } }
i use arraylist gridview data. when scroll down , scroll up, photos mixed. mixed means photos' position changed. why that? please, me ㅠㅜ
try this... use view holder holding details...
public view getview(int position, view convertview, viewgroup parent) { view view = convertview; final viewholder holder; if(convertview == null) { view = inflater.inflate(r.layout.phototab_list, parent, false); holder = new viewholder(); holder.photo = (imageview)convertview.findviewbyid(r.id.photos); holder.check = (checkbox)convertview.findviewbyid(r.id.photoscheck); holder.options = new bitmapfactory.options(); holder.options.insamplesize = 16; }else { holder = (viewholder) view.gettag(); } log.i("load", position + ""); if(receivephotos.get(position) == null) { receivephotos.set(position, bitmapfactory.decodefile((string)(receivedphoto.get(position)), options)); } holder.photo.setimagebitmap(receivephotos.get(position)); int check = photoischeck.get(position); if(check == 0) { holder.check.setchecked(false); } else { holder.check.setchecked(true); } return view; }
Comments
Post a Comment