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
URLurl=newURL("your url");
Bitmapbmp= BitmapFactory.decodeStream(url.openConnection().getInputStream());
imageView.setImageBitmap(bmp);
and
publicbooleanloadImageFromURL(String url, ImageView iv){
try {
URLmyUrl=newURL (url);
HttpURLConnectionconn=
(HttpURLConnection) myUrl.openConnection();
conn.setDoInput(true);
conn.connect();
InputStreamis= conn.getInputStream();
iv.setImageBitmap(BitmapFactory.decodeStream(is));
returntrue;
} catch (Exception e) {
e.printStackTrace();
}
returnfalse;
}
*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?"