How To Display An Image From A Url In A ListView In Android?
I am using json parsing in my application.I have a ListView which displays some data and also an ImageView.Here i want to display an image from another url in an ImageView.How to d
Solution 1:
Here its shown how to load the images in listview from a URL
And just for loading images from a URL there are a lot of SO threads
Solution 2:
Please visit
for listview for lazy loading implementations
https://github.com/square/picasso
Solution 3:
try this method
URL url = new URL("your url");
Bitmap bmp = BitmapFactory.decodeStream(url.openConnection().getInputStream());
imageView.setImageBitmap(bmp);
and
public boolean loadImageFromURL(String url, ImageView iv){
try {
URL myUrl = new URL (url);
HttpURLConnection conn =
(HttpURLConnection) myUrl.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
iv.setImageBitmap(BitmapFactory.decodeStream(is));
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
*remember : execute both methods in Asyntask.otherwise it will crash
Post a Comment for "How To Display An Image From A Url In A ListView In Android?"