Android - GridView滚动正在通用图像加载器中重新加载图像
问题描述:
我正在使用通用图像加载程序,但每次向上和向下滚动时都会重新加载图像。Android - GridView滚动正在通用图像加载器中重新加载图像
我正在使用下面的代码。
配置 - >
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
.memoryCache(new WeakMemoryCache())
.denyCacheImageMultipleSizesInMemory()
.discCacheFileNameGenerator(new Md5FileNameGenerator())
.tasksProcessingOrder(QueueProcessingType.LIFO)
// .enableLogging() // Not necessary in common
.build();
// Initialize ImageLoader with configuration.
ImageLoader.getInstance().init(config);
选项 - >
options = new DisplayImageOptions.Builder()
.resetViewBeforeLoading()
.imageScaleType(ImageScaleType.EXACTLY)
.cacheInMemory(true)
.bitmapConfig(Bitmap.Config.RGB_565)
.build();
视图 - >
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View workingview = inflater.inflate(R.layout.gridview_item_photo_icon, null);
ImageView imageView = (ImageView) workingview.findViewById(R.id.picture);
ImageAware imageAware = new ImageViewAware(imageView, false);
imageLoader.displayImage("file://" + imageUrls.get(position), imageAware, options, new SimpleImageLoadingListener());
return workingview;
}
请让我知道我要去哪里错了。
答
在1MB的图像兑现时,它有一个chache的限制,它可以清除缓存并再次下载,这就是为什么它会重新加载图像的原因。 如果您没有将图像下载到手机内存的SD卡中,这是正确的方法。 您无法在缓存中保存太多数据。