如何使用Android中的Drawable从url中获取多个图像?
private Drawable LoadImageFromWebOperations(String url) {
try {
InputStream is = (InputStream) new URL(url).getContent();
Drawable d = Drawable.createFromStream(is, "icon");
return d;
} catch (Exception e) {
System.out.println("Exc=" + e);
return null;
}
}
我正在使用此函数返回可绘制图像,但我没有得到如何将图像列表绑定到gridview ..
请帮帮我。
答案 0 :(得分:1)
只需将网址添加到“imgaeUrl”字段
即可URL url = new URL(imageUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
InputStream is = connection.getInputStream();
Bitmap img = BitmapFactory.decodeStream(is);
imageView.setImageBitmap(img );
并设置imageview
答案 1 :(得分:0)