首先需根据URL地址获取图片,如下所示,urladdr即为图片地址,返回Drawable对象:
//download image from network using @urladdress
private Drawable loadImageFromNetwork(String urladdr) {
// TODO Auto-generated method stub
Drawable drawable = null;
try{
//judge if has picture locate or not according to filename
drawable = Drawable.createFromStream(new URL(urladdr).openStream(), "image.jpg");
}catch(IOException e){
Log.d("test",e.getMessage());
}
if(drawable == null){
Log.d("test","null drawable");
}else{
Log.d("test","not null drawable");
}
return drawable;
}