我使用以下函数加载一个远程图像到ImageView。图像存在于URL,我想从URL中加载图像,但当我调用函数想显示图像时, ImageView仍是空白。为什么会出现这种情况啊?
public static void setImage(ImageView view, String url) throws IOException {
final URLConnection conn = new URL(url).openConnection();
conn.connect();
final InputStream is = conn.getInputStream();
final BufferedInputStream bis = new BufferedInputStream(is, 100000);
final Bitmap bm = BitmapFactory.decodeStream(bis);
bis.close();
is.close();
view.setImageBitmap(bm);
}