/*
* 获取网上的图片
*/
public class ImageTools {
public static Bitmap getIcon(String path) {
Bitmap bitmap = null;
try {
URL url = new URL(path);//创建URL连接
URLConnection connection = url.openConnection();//打开连接
InputStream stream = connection.getInputStream();//获取输输入流
bitmap = BitmapFactory.decodeStream(stream);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return bitmap;
}
}
Bitmap bitmap=ImageTools.getIcon("http://write.blog.csdn.net/postlist");
imageView.setImageBitmap(bitmap);