2

I am using GRAPH API to get posts of a facebook page. For posts which contains picture, the response contains the picture URL.

Response= {id:"...", message:"...",picture:"jpg image url"}

I am trying to load the image from the above URL resulted from GRAPH API.

And using below code to load image from URL. How to load an ImageView by URL in Android?

I see resulting bitmap is not null, but my imageview shows nothing(not even a default image I set in the XML).

Note: Image is a jpg format.

4

2 回答 2

1

试试这个库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);
于 2014-07-19T13:20:17.270 回答
0

自己发现错误:实际上图像正在加载上面的代码。我使用的是文本视图,然后是线性布局中的图像视图。当内容超出屏幕时,不显示图像(但 textview 默认滚动)。所以我使用了滚动视图,然后我可以看到图像,即使内容超出了屏幕。

于 2014-07-20T13:05:37.740 回答