KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have come across some very unexpected (and incredibly frustrating) functionality while trying to restore the state of a list of CheckBox es after a screen rotation. I figured I first would try to give a textual explanation without the code, in case someone is able to determine a solution without all the gory details. If anyone needs more details I can post the code. I have a scrolling list of complex View s that contain CheckBox es. I have been unsuccessful in restoring the state of these check boxes after a screen rotation. I have implemented onSaveInstanceState and have successfully transferred the list of selected check boxes to the onCreate method. This is handled by passing a long[] of database ids to the Bundle . In onCreate() I check the Bundle for the array of ids. If the array is there I use it to determine which check boxes to check when the list is being built. I have created a number of test methods and have confirmed that the check boxes are being set correctly, based on the id array. As a last check I am checking the states of all check boxes at the very end of onCreate( ). Everything looks good... unless I rotate the screen. When I rotate the screen, one of two things happens: 1) If any number of the check boxes are selected, except for the last one, all check boxes are off after a rotation. 2) If the last check box is checked before rotation, then all check boxes are checked after rotation. Like I said, I check the state of the boxes at the very end of my onCreate() . The thing is, the state of the boxes at the end of onCreate is correct based on what I selected before the rotation. However, the state of the boxes on the screen does not reflect this. In addition, I have implemented each check box's setOnCheckChangedListener(
Tags (comma-separated)
Save Edits
Cancel