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:
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?
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?