Android - Images are not displayed even though it has been loaded -


i set imageview layout width fix value , my layout height wrapcontent. images imageview loaded via url. happened , time view drawn, since image not yet loaded, draw layout_width . time images loaded, height no longer drawn, no image displayed. displayed if scroll , forth because, guess time view redrawn. there way can solve problem? using invalidate() did not work. maybe did wrong way?

i'll post snippets of code: getview of myadapter extends baseadapter:

 public view getview(int position, view convertview, viewgroup parent){     viewholder holder = null;      layoutinflater inflater = (layoutinflater) context.getsystemservice(activity.layout_inflater_service);      typeface typefacemyriadreg = typeface.createfromasset(context.getassets(), myriad_reg);       if(convertview == null){         convertview = inflater.inflate(r.layout.shop_list_layout, null);         holder = new viewholder();         holder.txtshopname = (textview) convertview.findviewbyid(r.id.name);         holder.txtshopname.settypeface(typefacemyriadreg);         holder.txtshopdesc = (textview) convertview.findviewbyid(r.id.desc);         holder.txtshopdesc.settypeface(typefacemyriadreg);         holder.imageview = (imageview) convertview.findviewbyid(r.id.prof_pic);         holder.progbar = (progressbar) convertview.findviewbyid(r.id.img_progress);            convertview.settag(holder);     }else{         holder = (viewholder) convertview.gettag();     }         imageloader=new imageloader(context.getapplicationcontext(), holder.progbar);      shoprowitem shopitem = (shoprowitem) getitem(position);      holder.txtshopname.settext(shopitem.getshopname());     holder.txtshopdesc.settext(shopitem.getshopdesc());     imageloader.displayimage(shopitem.getimageurl(), holder.imageview);      return convertview; } 

then part of imageloder:

  public void displayimage(string url, imageview imageview) {     imageviews.put(imageview, url);     bitmap bitmap=memorycache.get(url);     if(bitmap!=null){         imageview.setimagebitmap(bitmap);         progressbar.setvisibility(view.visible);     }     else     {         queuephoto(url, imageview);         progressbar.setvisibility(view.visible);      } }   // ... // ...      //used display bitmap in ui thread class bitmapdisplayer implements runnable {     bitmap bitmap;     phototoload phototoload;     public bitmapdisplayer(bitmap b, phototoload p){bitmap=b;phototoload=p;}     public void run()     {         if(imageviewreused(phototoload))             return;         if(bitmap!=null){              //should recalculations , adjustments here? ? ?              phototoload.imageview.setimagebitmap(bitmap);             progressbar.setvisibility(view.gone);         }            else{                 phototoload.imageview.setimageresource(stub_id);                 progressbar.setvisibility(view.visible);         }     } } 

you can solve issue placing loading image in imageview, till image data server..

public void displayimage(string url, imageview imageview) { imageviews.put(imageview, url); bitmap bitmap=memorycache.get(url); if(bitmap!=null){     imageview.setimagebitmap(bitmap);     progressbar.setvisibility(view.visible); } else {     queuephoto(url, imageview); //add line of code here.....     imageview.setimageresource(r.drawable.your_image_placeholder);     progressbar.setvisibility(view.visible);  } } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -