java - Load image, using AsyncTask -


i want open photos, set string representing address (http). create simpleadapter , pass strings.

final arraylist<hashmap<string,string>> categorylist = updatemenufromserver.getcategories(); final listview listcatalog = (listview)findviewbyid(r.id.listview); simpleadapter catadapter =new simpleadapter(this, categorylist, r.layout.category_,                     new string[] {"name", "image"},                     new int[] {r.id.producertext, r.id.producerimage});              listcatalog.setadapter(catadapter); 

r.id.producerimage treated class customimageview

public class customimageview extends imageview{      private static context context;        public customimageview(context context) {         super(context);         this.context = context;     }      public customimageview(context context, attributeset attrs) {         super(context, attrs);         this.context = context;     }     public customimageview(context context, attributeset attrs, int defstyle) {         super(context, attrs, defstyle);         this.context = context;     }      public void setimageuri (uri uri1){         try {             url url = new url(uri1.tostring());              loadimage load = new loadimage(url);             load.execute();          } catch (ioexception e) {             e.printstacktrace();         }     }      public class loadimage extends asynctask<void, void, drawable> {          private url url;         public loadimage(url url){             url = url;         }         @override         protected drawable doinbackground(void... voids) {             drawable showimage = null;             try {                 showimage = drawable.createfromstream(url.openstream(), null);             } catch (ioexception e) {                 //e.printstacktrace();             }              return showimage;         }          protected void onpostexecute(drawable showimage) {             if(showimage!=null)                 setimagedrawable(showimage.getcurrent());         }     } } 

listview when loading first element see change pictures , load other elements. question how can avoid , loading listview open pictures loaded.


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -