I am wanting to save the positions of the items marked in listView by means of a chekbox in each item. Each time I check the items, I only save the last checked data. To check I made it show with each check a Log of sparseBooleanArray.size () in the console. The result you give me is always 1. Be False or True. How to save all marked items?
public View getView(final int i, View view1, ViewGroup viewGroup) {
final GuardarCheckBoxPosition guardarCheck = new GuardarCheckBoxPosition(this);
Chekcompra.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
GuardarPositionListview(i,b);
return view1;
}
public void GuardarPositionListview(int position, boolean b){
SparseBooleanArray sparseBooleanArray = new SparseBooleanArray(0);
sparseBooleanArray.put(position,b); //aqui tendria que guardar a mi parecer
Log.i("BooleanArrayPosition:"," "+sparseBooleanArray.size());
}
The result of the Log when marking three squares in a row is:
12-21 22:05:00.313 3683-3683/? I/BooleanArrayPosition:: 1
12-21 22:05:10.298 3683-3683/? I/BooleanArrayPosition:: 1
12-21 22:05:11.732 3683-3683/? I/BooleanArrayPosition:: 1