我是新手,我有一个问题,我想用函数处理程序运行图像,但我失败了,比如在这个代码上运行图像的代码是什么?可以帮我解决这个问题吗?
Intent intent = getIntent();
String url= intent.getStringExtra("URL");
tombol2 = (Button) findViewById(R.id.button2);
iv = (ImageView) findViewById(R.id.imageView1);
Drawable d1=LoadImageFromWebOperations(url);
iv.setImageDrawable(d1);
}
private Drawable LoadImageFromWebOperations(String url)
{
try
{
InputStream is = (InputStream) new URL(url).getContent();
Drawable d = Drawable.createFromStream(is, "src name");
return d;
}catch (Exception e) {
System.out.println("Exc="+e);
return null;
}
}
}