Skip to content Skip to sidebar Skip to footer

How To Get Images From Internet And Past It In A ListView?

I'm doing my BlogApp. It gets all data from the Internet. I added three TextViews, but I have problem with getting images from JSON. I've tryed different ways but I still don't und

Solution 1:

Volley Library makes this work quite easy and handles all other related tasks itself. You can use ImageLoader or NetworkImageView.
Follow the link for how to acheive it: https://developer.android.com/training/volley/request.html


Solution 2:

First of all download image from url then set it into your imageView.

public class LoadImageFromURL extends AsyncTask{  
@Override  
protected Bitmap doInBackground(String... params) {  

try {
URL url = new URL("image-url");  
InputStream is = url.openConnection().getInputStream();  
Bitmap bitMap = BitmapFactory.decodeStream(is);  
return bitMap;  

} catch (MalformedURLException e) {

e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;

}
@Override  
protected void onPostExecute(Bitmap result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
yourImageview.setImageBitmap(result);
}

} 

I Hope it will help you..!


Post a Comment for "How To Get Images From Internet And Past It In A ListView?"