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...
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
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.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 eachProgressBar
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.In your adapter constructor
I have used the above with Universal Image Loader. A stub Image is displayed along with progress dialog at the center. Once Image is downloaded. Image is set to imageview and progress dialog disappears.
https://github.com/nostra13/Android-Universal-Image-Loader
What's LazyList?.
You can see the resulting snap shot. I have used the above for listview. It should be the same for gridview as well. For testing purpose i have used a default launcher image. But can remove the stud image, customize your progress dialog.