gpt4 book ai didi

Android Universal ImageLoader 多次加载同一张图片

转载 作者:行者123 更新时间:2023-11-30 00:53:37 25 4
gpt4 key购买 nike

我正在使用 UniversalImageLoader 加载图像。但我面临的问题是同一图像被多次加载。下面是日志输出。

日志:

11-11 11:10:21.342 26932-26932/com.example.sabudaniel61.ktdc D/ImageLoader: Load image from memory cache [http://loc8app.com/ktdcapp.in/ktdc/app/img/Aranya%20Nivas/room3.jpg_480x340]
11-11 11:10:21.342 26932-29175/com.example.sabudaniel61.ktdc D/ImageLoader: ImageAware is reused for another image. Task is cancelled. [http://loc8app.com/ktdcapp.in/ktdc/app/img/Aranya%20Nivas/room1.jpg_480x340]
11-11 11:10:21.342 26932-29175/com.example.sabudaniel61.ktdc D/ImageLoader: ImageAware is reused for another image. Task is cancelled. [http://loc8app.com/ktdcapp.in/ktdc/app/img/Aranya%20Nivas/room2.jpg_480x340]

主要 Activity .java:

ImageLoaderConfiguration config=new ImageLoaderConfiguration.Builder(getApplicationContext()).memoryCacheExtraOptions(480,800).threadPoolSize(5).threadPriority(Thread.NORM_PRIORITY-3).denyCacheImageMultipleSizesInMemory().memoryCacheSize(2*104*1024).memoryCacheSizePercentage(13).diskCacheSize(50*1024*1024).diskCacheFileCount(100).imageDownloader(new BaseImageDownloader(getApplicationContext())).defaultDisplayImageOptions(DisplayImageOptions.createSimple()).writeDebugLogs().build();
ImageLoader.getInstance().init(config);

HotelsFragment.java:

   DisplayImageOptions options=new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.ktdclogonew).showImageForEmptyUri(R.drawable.ktdclogonew).showImageOnFail(R.drawable.ktdclogonew).cacheInMemory(true).cacheOnDisk(true).considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565).build();
for(int i=0;i<Images.getInstance().AranyaGll.length;i++){
imageView=(ImageView) view.findViewById((Integer) imgs_ids.get(i));
ImageLoader.getInstance().displayImage(Images.getInstance().AranyaGll[i],imageView,options);
}

最佳答案

尝试替换这个:

DisplayImageOptions options = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.ktdclogonew).showImageForEmptyUri(R.drawable.ktdclogonew).showImageOnFail(R.drawable.ktdclogonew).cacheInMemory(true).cacheOnDisk(true).considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565).build();
for (int i = 0; i < Images.getInstance().AranyaGll.length; i++) {
imageView = (ImageView) view.findViewById((Integer) imgs_ids.get(i));
ImageLoader.getInstance().displayImage(Images.getInstance().AranyaGll[i], imageView, options);
}

有了这个:

DisplayImageOptions options = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.ktdclogonew).showImageForEmptyUri(R.drawable.ktdclogonew).showImageOnFail(R.drawable.ktdclogonew).cacheInMemory(true).cacheOnDisk(true).considerExifParams(true).bitmapConfig(Bitmap.Config.RGB_565).build();
for (int i = 0; i < Images.getInstance().AranyaGll.length; i++) {
//This is the change I made.
ImageView imageView = (ImageView) view.findViewById((Integer) imgs_ids.get(i));
ImageLoader.getInstance().displayImage(Images.getInstance().AranyaGll[i], imageView, options);
}

注意:我把图片 View 设为本地

关于Android Universal ImageLoader 多次加载同一张图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40542068/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com