首页 > 代码库 > android 显示internet 图片

android 显示internet 图片

try {

HttpGet httpRequest = new HttpGet(edtUrl.getText()
.toString());
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = (HttpResponse) httpclient
.execute(httpRequest);
HttpEntity entity = response.getEntity();
BufferedHttpEntity bufferedHttpEntity = new BufferedHttpEntity(
entity);
InputStream is = bufferedHttpEntity.getContent();
Bitmap bitmap = BitmapFactory.decodeStream(is);

ImageView iv = (ImageView) MainActivity.this
.findViewById(R.id.imageView1);

iv.setImageBitmap(bitmap);

} catch (Exception e) {
// TODO: handle exception
}