[英]how to load image from web?
hello all i have image url getting from web and now i want to display that in may imageview. 你好,我有从网络获取的图像网址,现在我想在5月imageview中显示它。
pls helm me out. 请帮助我。
Thanks In Advance. 提前致谢。
Below i mentioned one function that will load image from web and convert it into drawable . 下面我提到了一个将从Web加载图像并将其转换为drawable的函数。 So you can set that drawable into ImageView.
因此,您可以将可绘制对象设置为ImageView。
public static Drawable LoadImageFromWeb(String url)
{
try
{
InputStream is = (InputStream) new URL(url).getContent();
Drawable d = Drawable.createFromStream(is, "src name");
return d;
} catch (Exception e) {
return null;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.