进度在每个gridview的项目的Android [英] Progressbar in each gridview item Android
问题描述
我有一个显示的图像和进度条的GridView。每个项都包含进度条和相应的文件下载时显示进度。虽然滚动GridView控件,进度条多次显示了错误的项目进展情况和我使用的是viewholder。请给我一个解决方案...
I have a gridview showing images and progress bar. Each item contains progress bar and it shows progress when corresponding file downloads. While scrolling gridview, progress bar repeatedly shows progress in wrong items and i am using a viewholder. Please give me a solution...
推荐答案
的问题是,你的进度
对象越来越随意的系统,当他们滚动屏幕外重用。
The problem is that your ProgressBar
objects are getting reused arbitrarily by the system when they scroll offscreen.
这意味着,当一个进度
滚动屏幕外,在一个新的网格位置被重用为出现该项目。
This means that when one ProgressBar
scrolls offscreen, it is reused in a new grid position as that item appears.
该解决方案是相当容易的。在 getView()
必须设置进度值和知名度(如果你把它们藏在不使用时)每个进度
下载的状态irregardless。为了做到这一点,你将有进展值和下载状态保存每个网格的位置,这很可能已经可用。
The solution is fairly easy. In getView()
you must set the progress value and the visibility (if you are hiding them when not in use) of each ProgressBar
irregardless of the state of the download. In order to do this, you will have the progress value and download state for each grid position saved, which you probably already have available.
这篇关于进度在每个gridview的项目的Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!