使用动态URL中的Glide加载图像

时间:2015-09-18 20:06:41

标签: java android image android-glide

我在我的Android项目中使用Glide库来更新来自API的URL中的头像。 问题在于,当我尝试将不同的图片(来自不同的网址)加载到同一个imageView时,它会向我显示第一次下载的图片。(网址构建工作正常,我试过了它在浏览器中显示所需的图像)

这是我的代码: 的 EditProfileFragment.xml

public static final String IMAGE_BASE_URL = "http://myapi.com/img/";

String imageUrl = Const.IMAGE_BASE_URL + cb_getProfile.photo;  //imageName.jpg

                    Glide.with(mContext)
                            .load(imageUrl)
                            .animate(R.anim.abc_fade_in)
                            .centerCrop()
                            .into(mImageView_photo);

1 个答案:

答案 0 :(得分:2)

通过从网址加载图片时添加Glide.with(mContext) .load(imageUrl) .animate(R.anim.abc_fade_in) .signature(new StringSignature(String.valueOf(System.currentTimeMillis()))) .centerCrop() .into(mImageView_photo) ; 解决了此问题。 Source

{{1}}

感谢Yoav Sternberg。

相关问题