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();
        }

}

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

1 Comment

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.
0

you can used Lasylist for image display in listview.

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

1 Comment

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.