Android的通用映像,加载程序不会继续加载的图像上滚动的GridView控件加载、映像、控件、图像

2023-09-06 02:40:29 作者:万般努力只为出人头地

我使用 Android的通用映像,装载机库加载远程图片的ImageView中我的GridView细胞。

I am using Android-Universal-Image-Loader library to load a remote pictures to ImageView in my GridView cells.

在这里的ImageLoader的配置:

Here the the imageLoader configurations:

new ImageLoaderConfiguration.Builder(Config.context)
.threadPriority(Thread.NORM_PRIORITY - 2)
.memoryCacheSize(20 * 1024 * 1024) // 20 Mb
.memoryCache(new LruMemoryCache(20 * 1024 * 1024))
.defaultDisplayImageOptions(DisplayImageOptions.createSimple())
.tasksProcessingOrder(QueueProcessingType.LIFO)
.enableLogging() // Not necessary in common
.build();

和显示选项​​:

new DisplayImageOptions.Builder()
.showStubImage(R.drawable.blank)
.showImageForEmptyUri(R.drawable.no_image)
.build();

的问题: 一旦与GridView中开始一切工作正常,图像的活动出现在细胞内, 然后我格滚动下来(我在网格约20个项目)和其他图像加载正常。 但是,一旦我滚动其顶部已经再次加载启动加载的图片。

The problems: Once activity with the gridview starts all works properly and images appears in the cells, then I scroll grid down (I have about 20 items in the grid) and other images load properly. But once I scroll top the images which already loaded start loading again.

经过几次向上和向下滚动电网把所有照片,他们不消失了。

After a few scrolls up and down grid saves all images and they don't disappear anymore.

是否有人符合任何类似的问题,或者你知道我做错了什么。 感谢您的帮助。

Did someone meet any similar problems or you know what I did wrong. Thanks for help.

ADDED : 这里是我的适配器的getView方法:

ADDED: Here is the getView method in my adapter:

@Override
public View getView(final int position, View convertView, ViewGroup parent) {

    View view = convertView;
    ViewHolder holder;

    if ( view == null ) {           
        view = Config.context.getLayoutInflater().inflate(R.layout.featured, null);
        holder = new ViewHolder();

        holder.titleText = (TextView) view.findViewById(R.id.featured_title);
        holder.priceText = (TextView) view.findViewById(R.id.featured_price);
        holder.image = (ImageView) view.findViewById(R.id.thumbnail_image);

        view.setTag(holder);
    }
    else {
        holder = (ViewHolder) view.getTag();
    }

    HashMap<String, String> listing = listings.get(position);

    /* set text values */
    holder.titleText.setText(listing.get("title"));
    holder.priceText.setText(listing.get("price"));

    /* load image to list (AsyncTask) */
    Utils.imageLoaderFeatured.displayImage(listing.get("photo"), holder.image, Utils.imageLoaderOptionsFeatured);

    return view;
}

PS。让我知道如果你想看到其他code(格适配器可能),以帮助我解决这个问题。

PS. Let me know if you want to see other code (grid adapter maybe) to help me with this issue.

约翰·

推荐答案

我曾经遇到过的通用映像下载器演示了同样的问题,我希望图书馆开发商将问题解决在未来的更新。

I have encountered the same problem on Universal-Image-Loader Demo and I hope the Library developers will solve the problem in the next update.

更新:这个问题固定的帮助 nostra13 ,您必须更新库的 1.9版本,并用这种方式显示在画面的的ImageView

UPDATE: The problem fixed with help of nostra13, you have to update the library to 1.9 version and use this way of displaying pictures in the imageView:

ImageAware imageAware = new ImageViewAware(imageView, false);
imageLoader.displayImage(imageUri, imageAware);

这解决了我的问题。为什么你应该做这方面的一些细节可以发现,here这里

It solved my problem. Some details of why you should do this can be found here and here