可见,同时,旧项目在列表视图或GridView中,在回收利用 [英] Old items visible a while, in listview or gridview, when recycling

查看:172
本文介绍了可见,同时,旧项目在列表视图或GridView中,在回收利用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是不是一个大问题,但它看起来很奇怪。在列表或gridview的我有延迟(例如,从遥远的地方加载)加载图像。我回收的物品,使用convertView。当我快速向下滚动,我看到老照片反复,直到正确的图像获取和替换它们。

This is not a big issue, but it looks strange. In a list or gridview I load images with a delay (e.g. loaded from remote place). I'm recycling the items, using convertView. When I scroll down fast, I see the old images repeated, until the correct images are fetched and replace them.

有没有办法来改变呢?我试过了,例如,在 getView(),设置ImageView的能见度 GONE(初始化convertView后,如有必要)<一开始/ code>。和图像后设置为可见被取出。但由于某些原因,这不工作(看起来还是一样)。

Is there a way to change this? I tried, for example, at the very start of getView() (after initializing convertView, if necessary), to set the imageView visibility to GONE. And set to VISIBLE after the image has been fetched. But for some reason, this doesn't work (still looks the same).

谢谢!

编辑:我甚至不知道这是否是使用回收的意见时,或者如果我做错了正常的行为。它看起来并不像一个bug,当互联网连接速度快,或从文件系统进行读取时。然后将新的图像加载非常快,用户不看重复的项。但是,一个缓慢的互联网连接,它看起来像一个bug。

I'm not even sure if this is normal behaviour when using recycled views, or if I'm doing something wrong. It doesn't look like a bug when the internet connection is fast, or when fetching from the file system. Then the new images are loaded very fast and the user doesn't see repeated items. But on a slow internet connection, it looks like a bug.

推荐答案

在行设置图像只是检查,如果图像属于查看内容。

Before setting image in row just check if the image belong to the content of view.

我有同样的问题一段时间回来,我不得不改变我的形象下载所以,它需要图像URL以及元数据,以便一旦下载完成后,我可以查看的数据进行比较的元数据。

I had the same problem sometime back and I had to change my image downloader so that it takes image url as well as meta data so that once download is complete, i can compare meta-data with view's data.

这篇关于可见,同时,旧项目在列表视图或GridView中,在回收利用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆