1. 程式人生 > >把網路圖片轉換為bitmap並顯示在ImageView中

把網路圖片轉換為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);