I am using a ListView to display some images and captions associated with those images. I am getting the images from the Internet. Is there a way to lazy load the images so while the text displays, the UI is not locked up and images are displayed as they are downloaded? The number of images is not fixed.
Update:
(Using the below code, I have tried to download images and displaying in ListView)
Bitmap bmImg; Bitmap downloadFile(String fileUrl)
{
URL myFileUrl = null;
try {
myFileUrl = new URL(fileUrl);
}
catch (MalformedURLException e)
{
e.printStackTrace();
}
try {
HttpURLConnection conn = (HttpURLConnection) myFileUrl .openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bmImg = BitmapFactory.decodeStream(is);
} catch (IOException e)
{
e.printStackTrace();
}
return bmImg;
}
1 Answer