本文介绍了在列表视图回收早?抑或是通用ImageLoader的取消错误?或者是我的逻辑错了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它的工作原理漂亮,除了在ListView的第一项是有它的图像加载任务取消。

It works beautifuly except for the very first item in a listview is having its image loading task canceled.

它说,它,因为信息查看图像中较新的任务时重复使用图像加载任务被取消而正所谓

但由于观点显然仍清晰可见,这一观点不应该被回收没有?我使用convertView。

however since the view is clearly still visible, this view shouldn't be recycled yet? I am using convertView.

    @Override
    public View getView(int position, View convertView, ViewGroup parent)
    {
        if (getItemViewType(position) == HAS_IMAGE)
        {

            if (convertView == null)
            {
                convertView = li.inflate(R.layout.item_update_pic, null);
                new UpdateWithImageWrapper(convertView, position); // this is where views are looked up and set
            }
            ((UpdateWithImageWrapper) convertView.getTag()).setMyData(data.get(position), position); // this is where the correct data is set to the views and images are set to be loaded
        }
        else
        {
            if (convertView == null)
            {
                convertView = li.inflate(R.layout.item_update, null);
                new UpdateNoImageWrapper(convertView, position);
            }
            ((UpdateNoImageWrapper) convertView.getTag()).setMyData(data.get(position), position);
        }
        return convertView;
    }

有没有人有解决方案吗?

Does anyone have solution?

编辑:只是想补充一点,它有问题,与我所有的列表视图

just wanted to add that it has the issue with all of my list views.

使用ImageLoader的1.8.4

using ImageLoader 1.8.4

或许有办法从这么快循环停止的ListView?

Perhaps there is a way to stop the listview from recycling so quickly?

推荐答案

我终于想通了真正的答案。
在我的 ImageLoadingListener()

I finally figured out the real answer.in my ImageLoadingListener()

    @Override
    public void onLoadingCancelled(String imageUri, View view) { }

我的形象设定到重新presented加载错误形象。那么事实证明,如果我不改变的图像时,此方法被调用,然后一切工作正常。

I was setting the image to a image that represented a loading error. Well as it turns out, that if i do not change the image when this method is called then everything works fine.

所以,对我来说,真正的问题是,当onLoadingCancelled方法被调用,图像已经被加载,并且在这里设置的ImageView来重新presenting一个一个形象取消覆盖实像的成功加载。

So the real issue for me is that when the onLoadingCancelled method is called, the image has already been loaded, and setting the imageview here to a image representing a cancel overwrites a successful loading of the real image.

这篇关于在列表视图回收早?抑或是通用ImageLoader的取消错误?或者是我的逻辑错了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 11:28