我正在使用 GRAPH API
获取 facebook
页面的帖子。对于包含图片的帖子,响应包含图片 URL
。
Response= {id:"...", message:"...",picture:"jpg image url"}
我正在尝试从 GRAPH API
生成的上述 URL
加载图像。
并使用下面的代码从 URL 加载图像。 How to load an ImageView by URL in Android?
我看到生成的位图不为空,但我的 ImageView 没有显示任何内容(甚至没有我在 XML 中设置的默认图像)。
注意:图片为jpg
格式。
最佳答案
试试这个 图书馆https://github.com/nostra13/Android-Universal-Image-Loader
使用以下代码
ImageLoader imageLoader = ImageLoader.getInstance();
imageLoader.init(ImageLoaderConfiguration.createDefault(this));
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showStubImage(R.drawable.null_avtar) //this is the image that will be displayed if download fails
.cacheInMemory()
.cacheOnDisc()
.build();
imageLoader.displayImage(avtar_url, mImageView, options);
关于android: ImageView 不显示来自 URL 的位图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24840754/