我使用的是通用图像加载程序版本1.5.9,这是我的代码,我想要缓存图像以便每次重新加载活动时都不下载,我不需要关闭应用程序,但它每次下载图像:android -universal图像加载器无法从缓存加载
ImageLoader imageLoader = ImageLoader.getInstance();
File cacheDir = StorageUtils.getCacheDirectory(context);
config= new ImageLoaderConfiguration.Builder(context)
.memoryCacheExtraOptions(480, 800) // default = device screen dimensions
.diskCacheExtraOptions(480, 800, null)
.threadPriority(Thread.NORM_PRIORITY - 2) // default
.tasksProcessingOrder(QueueProcessingType.FIFO) // default
.diskCache(new UnlimitedDiskCache(cacheDir)) // default
.diskCacheSize(50 * 1024 * 1024)
.diskCacheFileCount(100)
.diskCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default
.imageDownloader(new BaseImageDownloader(context)) // default
.build();
imageLoader.init(config);
imageLoader.displayImage(img, viewHolder.img);
问题是什么?为什么每次都下载图像?
您是否正在从网址载入图片? –
为什么你不使用通用图像加载器的地方滑行,请参阅此链接:https://github.com/bumptech/glide –
@AishwaryaTiwari是的,我从url加载它 –