I have a few CheckBox
elements inside one of my Fragments
.
Every time I leave this Fragment it seems to nor save or restore the checked state of each one provided by the user.
In the FragmentList
example you can find:
CheckBox check1;
boolean active;
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean("state1", check1.isChecked());
}
Which you can use later like this:
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (savedInstanceState != null) {
// Restore last state for checked position.
check1.setChecked(savedInstanceState.getBoolean("state1"));
}
}
But somehow the CheckBox
elements don`t save their state.
Is this the correct approach I should take?