java - get unchecked and checked values from a checkbox -


i'm trying print contents of checkbox list. i'd display unchecked (false values) , checked (true values) in order appears in list view. far can true values, how can unchecked false values?

public void selection (){     final listview lv = (listview)findviewbyid(r.id.treequestionslist);     intent intent = getintent();      int id2 = intent.getintextra("id2", 0);     sparsebooleanarray checked = lv.getcheckeditempositions();     int size = checked.size();      (int = 0; < size; i++) {         int key = checked.keyat(i);      entries.add(new observation(id2,lv.getcheckeditempositions().get(key)));          log.d(constants.tag,"--id:="+id2+"--checkeddata----"+ entries.get(i).answers);     }  } 

from documentation available on android developers, might need use combination of value along key in order desired result.

for (int i=0; < checked.size(); i++) {     if (checked.valueat(i)) {         int key = checked.keyat(i);         log.i(tag, key + " selected");     } else {         int key = checked.keyat(i);         log.i(tag, key + " not selected");     } } 

you can take @ getcheckeditempositions() does.


Comments