把网络图片转换为bitmap并显示在ImageView中

1.把网络图片转换成Bitmap

public static Bitmap getImage(String path) throws Exception{
		URL url = new URL(path);
		HttpURLConnection conn = (HttpURLConnection) url.openConnection();
		InputStream is = conn.getInputStream();
		return BitmapFactory.decodeStream(is);
	}
2.把bitmap显示在ImageView中

首先用findViewById找到ImageView

然后,

mImageView.setImageBitmap(bitmap);



你可能感兴趣的:(android)