Android ExpandableList - Image Loader - Simple Adapter -


i need our help.

i need create expandablelistview , put inside more images loaded url.

now have this:

i take text file xml dunno how show in image image dinamic.

this code:

main.java  public class main extends expandablelistactivity {       static final string key_discounted_price = "discounted_price";     static final string key_price = "price";     static final string key_discount = "discount";     static final string key_thumb_url_seller = "seller_image_url";     static final string key_thumb_url = "image_url";     static final string key_description = "description";     static final string key_title_offerta = "title_offerta";         string contenuto_nodo;     arraylist <string> array_contenuto_nodo =new arraylist<string>();     arraylist<hashmap<string, string>> songslist = new arraylist<hashmap<string, string>>();         static final string shades[][] = { // shades of grey       {         "lightgrey","#d3d3d3",         "dimgray","#696969",         "sgi gray 92","#eaeaea"       }, // shades of blue       {         "dodgerblue 2","#1c86ee",         "steelblue 2","#5cacee",         "powderblue","#b0e0e6"       }, // shades of yellow       {         "yellow 1","#ffff00",         "gold 1","#ffd700",         "darkgoldenrod 1"," #ffb90f"       }, // shades of red       {         "indianred 1","#ff6a6a",         "firebrick 1","#ff3030",         "maroon","#800000"       }     };      /** called when activity first created. */     @override     public void oncreate(bundle icicle)     {         super.oncreate(icicle);         setcontentview(r.layout.main);           taskhomepagelista task = new taskhomepagelista();         task.execute();         try {thread.sleep(5000);         } catch (interruptedexception e) {             // todo auto-generated catch block             e.printstacktrace();         }           // imageloader class instance          simpleexpandablelistadapter explistadapter =             new simpleexpandablelistadapter(                 this,                 creategrouplist(),  // groupdata describes first-level entries                 r.layout.list_row,  // layout first-level entries                 new string[] { key_price, key_discount, key_description, key_discounted_price, key_title_offerta},  // key in groupdata maps display                 new int[] { r.id.price, r.id.discount, r.id.description, r.id.discounted_price, r.id.title_offerta},        // data under "colorname" key goes textview                  createchildlist(),  // childdata describes second-level entries                 r.layout.child_row, // layout second-level entries                 new string[] { "shadename", "rgb" },    // keys in childdata maps display                 new int[] { r.id.childname, r.id.rgb }             );           setlistadapter( explistadapter );           // imageview show       }  /**   * creates group list out of colors[] array according   * structure required simpleexpandablelistadapter. resulting   * list contains maps. each map contains 1 entry key "colorname" ,   * value of entry in colors[] array.   */     private list creategrouplist() {         return (list)songslist;     }  /**   * creates child list out of shades[] array according   * structure required simpleexpandablelistadapter. resulting list   * contains 1 list each group. each such second-level group contains   * maps. each such map contains 2 keys: "shadename" name of   * shade , "rgb" rgb value shade.   */   private list createchildlist() {     arraylist result = new arraylist();     for( int = 0 ; < shades.length ; ++i ) { // second-level lists       arraylist seclist = new arraylist();       for( int n = 0 ; n < shades[i].length ; n += 2 ) {         hashmap child = new hashmap();         child.put( "shadename", shades[i][n] );         child.put( "rgb", shades[i][n+1] );         seclist.add( child );       }       result.add( seclist );     }     return result;   }      @override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu; adds items action bar if present.         getmenuinflater().inflate(r.menu.main, menu);         return true;     }       class taskhomepagelista extends asynctask<string, void, void> {             protected void onpreexecute(void... params) {          }          protected void doinbackground(string... args) {              try {                  // passo parametri di mail e password alle variabili                    //setto la pagina                 httpclient httpclient = new defaulthttpclient();                 httpcontext localcontext = new basichttpcontext();                 httppost httppost = new httppost("http://www.miosito.homepagexml.aspx");                  // aggiungo alla lista le variabili                  // chiamo la pagina che mi da una risposta.                  httpresponse response = httpclient.execute(httppost, localcontext);                  inputstream in = response.getentity().getcontent();                  documentbuilder builder = documentbuilderfactory.newinstance()                         .newdocumentbuilder();                 document doc = builder.parse(in);                 string[] nomi = new string[6];                 nomi[0] = "price";                 nomi[1] = "image_url";                 nomi[2] = "seller_image_url";                 nomi[3] = "discount";                 nomi[4] = "discounted_price";                 nomi[5] = "description";                     if (doc != null) {                     // dichiaro n3 per la lunghezza dell'item principale di quello che devo selezionare.                       nodelist n3 = doc.getelementsbytagname("promo");                         nodelist n2 = doc.getelementsbytagname("home");                     (int = 0; < n3.getlength(); i++) {                          hashmap<string, string> map = new hashmap<string, string>();                         for( int num=0; num < nomi.length; num++){                         n2 = doc.getelementsbytagname(nomi[num]);                              if (n2.getlength() > 0) {                             node node = n2.item(i);                              contenuto_nodo = node.gettextcontent();                             array_contenuto_nodo.add(contenuto_nodo+"///");                                   if(nomi[num].equals("price")){                                 map.put(key_price, "valore" + html.fromhtml("<br>" + node.gettextcontent() + " €"));                                  }                                  if(nomi[num].equals("image_url")){                                 map.put(key_thumb_url, node.gettextcontent());                                 }  //                              if(nomi[num].equals("seller_image_url")){ //                              map.put(key_thumb_url_seller, node.gettextcontent()); //                              }                                  if(nomi[num].equals("discount")){                                 map.put(key_discount, "sconto" + html.fromhtml("<br>" + node.gettextcontent() + " %"));                                 }                                  if(nomi[num].equals("discounted_price")){                                 map.put(key_discounted_price, node.gettextcontent()+ " €");                                 }                                 if(nomi[num].equals("description")){                                 map.put(key_description, node.gettextcontent());                                 }                                  system.out.println("sto elaborando");                                  }                              n2 = doc.getelementsbytagname("home");                             }                            n2 = doc.getelementsbytagname("promo");                         if (n2.getlength() > 0) {                             node node = n2.item(i);                                node = node.getfirstchild();                              map.put(key_title_offerta, node.gettextcontent());                         }                           songslist.add(map);                       }                   system.out.println("array_titolo_categoria_home is: "  + array_contenuto_nodo );   //              controllo_login_tempo = "finito";                 }             } catch (exception e) {                 e.printstacktrace();             }                return null;          }          protected void onpostexecute(void... params) {          }          }     } 

in key_thumb_url after asynktask have url of image. need show @ harth image loader. dunno how implement image loader in simpleexpandablelistadapter. please me important!

i think can use this:

int loader = r.drawable.loader;  // imageview show imageview image = (imageview) findviewbyid(r.id.image);  // image url string image_url = "http://api.androidhive.info/images/sample.jpg";  // imageloader class instance imageloader imgloader = new imageloader(getapplicationcontext());  // whenever want load image url // call displayimage function // url - image url load // loader - loader image, displayed before getting image // image - imageview  imgloader.displayimage(image_url, loader, image); 

but dunno must put code... please help!

look image screen http://www.magicfly.it/app/screen.jpg

finally found solution.

"this class can used external clients of simpleadapter bind values views. should use class bind values views not directly supported simpleadapter or change way binding occurs views supported simpleadapter."

so imageview. expected bind value resource id or string , setviewimage(imageview, int) or setviewimage(imageview, string) invoked.

public class myviewbinder implements viewbinder {

    @override     public boolean setviewvalue(view view, object data,      string textrepresentation) {          if ((view instanceof imageview) & (data instanceof bitmap)) {              imageview iv = (imageview) view;              bitmap bm = (bitmap) data;              iv.setimagebitmap(bm);              return true;          }         return false;     }  } 

and

   hashmap<string, object> man = new hashmap<string,object>();                     bitmap bitmap = bitmapfactory.decodestream(aurl.openstream());                     modles.put(samurl,bitmap); 

then

adapter.setviewbinder(new myviewbinder()); //its below declaration of adapter 

source : click here


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -