performance - ListView Values are being duplictaed upon scrolling -


i using listview s.t every row have imageview , flowlayout, extended baseadapter , send arraylisy of hashmaps each 1 have image path , list of words problem every time scroll entry "leaves" screen , down , entry "comes back" screen words in entry flowlayout gets recycled being duplicated (meaning if word next disk-on-key "dok" after scroll down , again word in flowlayout "dok dok")...i cant figure out why... =(

i took flowlayout + bubbles here - http://www.superliminal.com/sources/flowlayout.java.html http://nishantvnair.wordpress.com/2010/09/28/android-create-bubble-like-facebook/

and decode async task load images list @mceley's answer here - large listview containing images in android

and getview code -

@override public view getview(int position, view convertview, viewgroup parent) {     imageview imageview = null;     flowlayout flowlayout = null;     if (convertview == null) {         convertview = layoutinflater.inflate(r.layout.list_item, null);         imageview = (imageview) convertview.findviewbyid(r.id.list_image);         flowlayout = (flowlayout) convertview.findviewbyid(r.id.flow_tags);     } else {         imageview = (imageview) convertview.findviewbyid(r.id.list_image);         flowlayout = (flowlayout) convertview.findviewbyid(r.id.flow_tags);         decodetask task = (decodetask) imageview.gettag(r.id.list_image);         if (task != null) {             task.cancel(true);         }     }     hashmap<string, list<string>> photos = new hashmap<string, list<string>>();     photos = data.get(position);     imageview.setimagebitmap(null);     decodetask task = new decodetask(imageview);     task.execute(photos.get(databasehandler.key_path).get(0));     imageview.settag(r.id.list_image, task);      arraylist<string> subjects = new arraylist<string>();     int size = photos.get(databasehandler.key_tags).size();     (int = 0; < size; i++) {         string name = string.format("name - %s ",                 photos.get(databasehandler.key_tags).get(i));         bubble.getbubble(name, flowlayout, subjects, activity,                 photos.get(databasehandler.key_path).get(0), false, false);     }      return convertview; } 

tnx in advance..!

use code in adapter.it should re-use row if not null , delete duplicated row.

 @override public view getview(int position, view convertview, viewgroup parent) {      // viewholder keeps references children views avoid unneccessary     // calls     // findviewbyid() on each row.     viewholder holder;     // when convertview not null, can reuse directly, there no     // need     // reinflate it. inflate new view when convertview     // supplied     // listview null.      if (convertview == null) {          convertview = minflater.inflate(r.layout.sample, null);         // creates viewholder , store references 2 children         // views         // want bind data to.         holder = new viewholder();         holder.name = (textview) convertview.findviewbyid(r.id.text);         holder.icon = (imageview) convertview.findviewbyid(r.id.icon);         convertview.settag(holder);     } else {         // viewholder fast access textview         // , imageview.          holder = (viewholder) convertview.gettag();      }      // bind data efficiently holder.     holder.name.settext(myelements.get(id));     holder.icon.setimagebitmap(micon1);      return convertview; }  static class viewholder {     textview  name;     imageview icon; } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -