1

I am facing problems while downloading images from array of urls to show list of images. I am storing image urls into one array and when i iterate this array i am calling a method to download and return a bitmap by passing one url at one time. But after completing this iteration i am missing some images. That means i came to know that the iteration process skipping some images.

Can any one help me in this? For reference purpose i am attaching my code here, which I am running in separate thread with handler.

Bitmap[] data = new Bitmap[urls.size()];
for (int i = 0; i < urls.size(); i++) {
Bitmap temp=getBitmapFromURL(urls.get(i));
if(temp!=null){
    data[i] = temp;
                }
}
public static Bitmap getBitmapFromURL(String urlString) {
        try {
         URL url = new URL(urlString);
         InputStream input = url.openConnection().getInputStream();

           BitmapFactory.Options options = new BitmapFactory.Options();

                    options.inSampleSize = 8; 


                myBitmap = BitmapFactory.decodeStream(input, null, options);
            return myBitmap;
        }catch (Exception e) {
            e.printStackTrace();
        }

}
sathish
  • 1,375
  • 6
  • 17
  • 31

2 Answers2

1

The lazyloading of images will solve your issue. Please go the the following link: Lazy load of images in ListView

Community
  • 1
  • 1
Basil
  • 2,163
  • 2
  • 16
  • 25
  • Thanks for your quick response. Lazy loading should work if i want to download and display images in a list view directly. but my intention is i want to download images from back end then storing them in bitmap array and then display them after completion of downloading all images. – sathish Jun 29 '11 at 13:37
0

you can used Lasylist for image display in listview.

Source is available here http://open-pim.com/tmp/LazyList.zip

Nikhil
  • 16,194
  • 20
  • 64
  • 81
  • Thanks for your quick response. Lazy loading should work if i want to download and display images in a list view directly. but my intention is i want to download images from back end then storing them in bitmap array and then display them after completion of downloading all images – sathish Jun 29 '11 at 13:37