2012年11月9日 星期五

[Android]設定URL圖片給ImageView

private Bitmap myBitmap;
URL myImageURL = null;


try {

myImageURL = new URL(imageURL);

HttpURLConnection connection = (HttpURLConnection)myImageURL .openConnection();

connection.setDoInput(true);

connection.connect();

InputStream input = connection.getInputStream();

myBitmap = BitmapFactory.decodeStream(input);

}