java - checkBox is checked ? Looping inside checkbox elements -
int count = listview.getchildcount(); (int = 0; < count; i++) { view child = list.getchildat(i); //check child.. }
i wanted use following code see if total number of checkbox(es) checked or not. if have 3 checkboxes want equivalent to:
if(!list.getchildat(0) && !list.getchildat(1) && !list.getchildat(2)){ // unchecked checkbox }
how loop through this, because 1 not sure number of contents in checkbox.
just modify if statement return state of checkbox.
int count = listview.getchildcount(); boolean allunchecked = true; (int = 0; < count; i++) { object child = (object) listview.getchildat(i); if (child instanceof checkbox) { checkbox checkboxchild = (checkbox) child; if (checkboxchild.ischecked()) { allunchecked = false; //one checked, sufficient not unchecked break; //get out loop } } }
allunchecked
true if checkboxes unchecked, false otherwise
i'm not android developer , can't find docs getchildat
don't know returns. if object can omit cast.
its check null
return of getchildat
too.
ps: not code, can take pseudo-code know how implement logic of how checked or not, getting list of checkboxes task :)
Comments
Post a Comment