获取网络图片地址,把返回图片转成Bitmap,然后用image View直接展示即可
public Bitmap getImageBitmap() {
URL imgUrl = null;
Bitmap bitmap = null;
try {
imgUrl = new URL("传地址");
HttpURLConnection conn = (HttpURLConnection) imgUrl.openConnection();
conn.setDoInput(true);
conn.connect();
InputStream is = conn.getInputStream();
bitmap = BitmapFactory.decodeStream(is);
is.close();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return bitmap;
}
展示图片
image.setImageBitmap(bitmap);