I have image url in string as
String imgurl=days.getString("icon_url");
getting this url jsonarray
which is saved in shared preference
how to show this string image url into ImageView
?
Any help???
I have image url in string as
String imgurl=days.getString("icon_url");
getting this url jsonarray
which is saved in shared preference
how to show this string image url into ImageView
?
Any help???
You can either use UniversalImageLoader or picasso Library to load image in imageview from url.
Add internet permission in your AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
And to download image using AsyncTask use following code:
private class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
ImageView bmImage;
public DownloadImageTask(ImageView bmImage) {
this.bmImage = bmImage;
}
protected Bitmap doInBackground(String... urls) {
String urldisplay = urls[0];
Bitmap mIcon11 = null;
try {
InputStream in = new java.net.URL(urldisplay).openStream();
mIcon11 = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return mIcon11;
}
protected void onPostExecute(Bitmap result) {
bmImage.setImageBitmap(result);
}
}
And to use above code to load image from url in imageview use following code:
new DownloadImageTask(mImageView).execute(imgurl);