I have been racking my brain and scouring many posts, but can't seem to find the answer to the dreaded state of the Expandable ListView/Checkbox problems. I can't get this to save the state. With ListView, I created a ListArray which would add and remove the position accordingly. I thought that the way around this would be to create a HashMap to do exactly the same, but it doesn't work.
Does anyone have an example of this working and the state of the checkboxes being saved?
Here is it working in ListView, but I need something similar with a HashMap -
private ListArray<Integer> checkedState = new ListArray<Integer>();
holder.checkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(isChecked){
checkedState.add(childPosition);
holder.checkbox.setSelected(true);
//Toast.makeText(_context,holder.txtListChild.getText() + " Selected",Toast.LENGTH_SHORT).show();
}
else{
holder.checkbox.setSelected(false);
checkedState.remove(childPosition).
//Toast.makeText(_context,holder.txtListChild.getText() + " UnSelected",Toast.LENGTH_SHORT).show();
}
}
});
if(checkedState.contains((Integer)childposition) {
holder.checkbox.setChecked(true);
} else {
holder.checkbox.setChecked(false);
}