jagku
asked on
maintaining the state of checkboxes on android listviews
Hello Experts,
I am using a listview with checkboxes.
I manually set the the checkboxes.
I want to pre-set the checkboxes again when I come back to the listview.
Please can you give me the command to programatically set the checkboxes when the listview is re-loaded (I know how to store the details of the checkboxes that were checked).
Many Thanks!
I am using a listview with checkboxes.
I manually set the the checkboxes.
I want to pre-set the checkboxes again when I come back to the listview.
Please can you give me the command to programatically set the checkboxes when the listview is re-loaded (I know how to store the details of the checkboxes that were checked).
Many Thanks!
ASKER
Thank you. However, I would like to clarify that I am trying to set the checkboxes that come with a listview. (They are not checkboxes that i have created in a layoutfile)
Hi jagku,
Use the
SparseBooleanArray sparseBooleanArray = myList.getCheckedItemPositions();
This method will return the selected state of the ListView.
Refer this link for some samples...
http://android-coding.blogspot.in/2011/09/listview-with-multiple-choice.html
Regards
Santhana
Use the
SparseBooleanArray sparseBooleanArray = myList.getCheckedItemPositions();
This method will return the selected state of the ListView.
Refer this link for some samples...
http://android-coding.blogspot.in/2011/09/listview-with-multiple-choice.html
Regards
Santhana
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
See above answer
http://stackoverflow.com/questions/6800244/android-how-to-save-the-state-of-a-checkbox
i also found this:
http://stackoverflow.com/questions/10613325/how-can-i-maintain-the-state-of-a-checkbox-even-after-navigating-to-different-ac