如何在毕加索中清除缓存并重新加载图像? [英] How to clear cache and Reload Image in Picasso?
问题描述
我正在使用 Picasso
在我的应用程序中加载图像,但我面临的问题是我的图像 URL
相同但图像正在从 backend
更改> 调用相同的 URL 但 Picasso
加载保存在其缓存中的相同图像.现在我想清除该图像的缓存并再次重新加载图像.
I am using Picasso
to load image in my application but i facing a issue that my image URL
is same but image is changing from backend
calling the same URL but Picasso
loading the same image saved in its cache. Now i want to clear the cache for that Image and reload the image again.
我在 SO 上搜索过的尝试发现我们可以使用 picasso.invalidate(fileName);
或 memoryPolicy(MemoryPolicy.NO_CACHE)
但我在代码中收到错误消息
What i have tried i searched on SO find that we can use picasso.invalidate(fileName);
or memoryPolicy(MemoryPolicy.NO_CACHE)
but i am getting the error message in code
无法使 reslove 方法失效
Can't reslove method invalidate
无法重新调用方法 memoryPolicy
Can't reslove method memoryPolicy
gradle 中毕加索的依赖:
dependency for picasso in gradle :
compile 'com.squareup.picasso:picasso:2.4.0'
推荐答案
invalidate()
和 memoryPolicy()
是在库的更高版本中引入的.要使用其中任何一个,请将 picasso 更新到最新版本
invalidate()
and memoryPolicy()
were introduced in later versions of the library. To use either of them update picasso to the latest version
compile 'com.squareup.picasso:picasso:2.5.2'
这篇关于如何在毕加索中清除缓存并重新加载图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!