Reputation: 1395
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();
}
}
Upvotes: 1
Views: 1649
Reputation: 2173
The lazyloading of images will solve your issue. Please go the the following link: Lazy load of images in ListView
Upvotes: 1
Reputation: 16196
you can used Lasylist for image display in listview.
Source is available here http://open-pim.com/tmp/LazyList.zip
Upvotes: 0