android - Inserting imageView from a JSON object, image file on the internet -


i showing json objects on list view in android.

this piece of code using populate rows:

public view getview(int position, view convertview, viewgroup parent) {         view v = convertview;          if(v == null) {             layoutinflater li = layoutinflater.from(getcontext());             v = li.inflate(r.layout.ofertas_app_custom_list, null);                    }          ofertas_application app = items.get(position);          if(app != null) {             imageview icon = (imageview)v.findviewbyid(r.id.imageview1);             textview titletext = (textview)v.findviewbyid(r.id.textview1);             textview direcciontext = (textview)v.findviewbyid(r.id.textview2);             textview valoraciontext = (textview)v.findviewbyid(r.id.textview3);              if(titletext != null) titletext.settext(app.getnombreempresa());//populate textview1              if (direcciontext !=null) direcciontext.settext(app.getdireccionempresa());//populate textview2      //what need comes here, app.getimagenempresa stores image name, , url image http://mujercanariasigloxxi.appgestion.eu/imagenes          }          return v;     } 

now need populate imageview1 image name stored @

app.getimagenempresa() 

any welcome. thank in advance.

do below :

imageview img = (imageview) findviewbyid(r.id.imageview1); try {     url url = new url("your url");     //try url = "http://0.tqn.com/d/webclipart/1/0/5/l/4/floral-icon-5.jpg"     httpget httprequest = null;      httprequest = new httpget(url.touri());      httpclient httpclient = new defaulthttpclient();     httpresponse response = (httpresponse) httpclient             .execute(httprequest);      httpentity entity = response.getentity();     bufferedhttpentity b_entity = new bufferedhttpentity(entity);     inputstream input = b_entity.getcontent();      bitmap bitmap = bitmapfactory.decodestream(input);      img.setimagebitmap(bitmap);  } catch (exception ex) {  }     

or use picasso / volley same , features caching.


Comments

Popular posts from this blog

Why can rails not find a route created by a helper? -

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -