File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Android and the fly likes problem in gridview while scrolling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "problem in gridview while scrolling" Watch "problem in gridview while scrolling" New topic

problem in gridview while scrolling

Suzzane Pinto
Ranch Hand

Joined: Feb 10, 2012
Posts: 214
hi all...

Iam stuck with a strange problem since long...
i have a gridview with images and checkbox and the problem is after selecting the image with checkbox when i scroll down..the above selected checkboxes become uncheckd...
i have no idea why this is code for the adapter class is like

looking for the hint...which could solve my issue....
i would be really greatful

James Do

Joined: Sep 24, 2012
Posts: 2
these scrolling view reuse Views rather than continuing to create a new one for every item in the list (or grid)
Therefore if your device is able to fit 15 items on the screen, you will only be asked to create 15 views. If you scroll up so that the top row disappears, those Views will be reused on the bottom row rather than requiring new Views to be created.

Coming back to your code, it should now be obvious that you set the checked state when the View is created, but not when it is reused.
Rather than relying on the View to maintain the checked state you should have a custom object associated with the current view and update the custom object when the check state changes.
I agree. Here's the link:
subject: problem in gridview while scrolling
jQuery in Action, 3rd edition