Android 图像在ImageView中未更改

Android 图像在ImageView中未更改,android,universal-image-loader,picasso,Android,Universal Image Loader,Picasso,我正在用android做一个ImageLoad的演示,我先使用了UniversalImageLoader,然后使用了picasso,然后使用了ImageLoader类,但每次当我将新图像上传到服务器并成功上传到服务器时,以及当我试图将其设置为ImageView时,之前加载的图像是一样的,它没有改变,我很沮丧,浪费了2天的时间来解决这个问题,没有运气,请帮助我拯救我的生命 我的代码如下: Picasso.with(getApplicationContext()) .load

我正在用android做一个ImageLoad的演示,我先使用了
UniversalImageLoader
,然后使用了
picasso
,然后使用了
ImageLoader
类,但每次当我将新图像上传到服务器并成功上传到服务器时,以及当我试图将其设置为
ImageView
时,之前加载的图像是一样的,它没有改变,我很沮丧,浪费了2天的时间来解决这个问题,没有运气,请帮助我拯救我的生命

我的代码如下:

Picasso.with(getApplicationContext())
            .load(Pref.getValue(getApplicationContext(),
                    Const.PREF_PROFILE_PIC, "")).into(iv_profile);

    Picasso.with(getApplicationContext())
            .load(Pref.getValue(getApplicationContext(),
                    Const.PREF_COVER_PIC, "")).into(iv_cover);

尝试在url末尾添加一个
cachebreaker

String imageurl1 = Const.PREF_PROFILE_PIC + "?" + new Date().getTime();
String imageurl2 = Const.PREF_COVER_PIC + "?" + new Date().getTime();

Picasso.with(getApplicationContext())
        .load(Pref.getValue(getApplicationContext(),
                imageurl1, "")).into(iv_profile);

Picasso.with(getApplicationContext())
        .load(Pref.getValue(getApplicationContext(),
                imageurl2, "")).into(iv_cover);

这将在您创建图像时自动附加当前时间戳,并使浏览器再次查找图像,而不是检索缓存中的图像。

想法与上述相同。但这对我不起作用

我从中得到了答案

更改您的URL,如下所示:

String imageurl = url + "?time=" + System.currentTimeMillis();
Picasso.with(getContext()).load(imageurl).into(imageView);

这对我有用。感谢

毕加索、UniversalImageLoader或任何其他图像加载库正在使用图像缓存来重新加载图像。因此,您需要更改新图像的名称或清除图像缓存以加载新图像。感谢neeraj的回复,但我正在从服务器获取此图像url,因此我无法更改url。还有其他解决方案吗?请。我将等待您的回复。您是否修改图像url?哦,我的天哪…您是天才曼恩。。。!!非常感谢,你救了我一天…尼拉杰,上帝保佑。。!!!我今天学到了一些东西。谢谢你的
cachebreaker
/
cachebuster
thing@KNeerajLal