• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Access data from non visible children in GridView

CIOC

Lurker
I have a GridView with some images, each image also have a checkbox associated with it, I'm trying to check the state of all checkboxes, for that I have this code:

Java:
for (int i = 0; i < gridView.getChildCount(); i++) {
   View child = gridView.getChildAt(i);
   CheckBox checkBox = (CheckBox) child.findViewById(R.id.checkBox);

   if(checkBox.isChecked())
       // do something
}

I know that gridView.getChildCount() returns only the visible items, I can also get the count from the adapter like this gridView.getCount() but of couse that will throw an null pointer exception when trying to access the checkbox as that object does not exists if it's not visible.

Is there a way to access the checkbox even when the image is not visible?
 
Back
Top Bottom