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.
publicclassLoadImageFromURLextendsAsyncTask{
@Overrideprotected Bitmap doInBackground(String... params) {
try {
URLurl=newURL("image-url");
InputStreamis= url.openConnection().getInputStream();
BitmapbitMap= BitmapFactory.decodeStream(is);
return bitMap;
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
returnnull;
}
@OverrideprotectedvoidonPostExecute(Bitmap result) {
// TODO Auto-generated method stubsuper.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?"