Skip to content

Instantly share code, notes, and snippets.

@dbachelder
Created February 19, 2014 22:52
Embed
What would you like to do?
Save instance state in android compound component From http://www.charlesharley.com/2012/programming/views-saving-instance-state-in-android/
protected Parcelable onSaveInstanceState() {
Parcelable superState = super.onSaveInstanceState();
return new SavedState(superState, numberPicker1.getValue(), numberPicker2.getValue(), numberPicker3.getValue());
}
@Override
protected void onRestoreInstanceState(Parcelable state) {
SavedState savedState = (SavedState) state;
super.onRestoreInstanceState(savedState.getSuperState());
numberPicker1.setValue(savedState.getNumber1());
numberPicker2.setValue(savedState.getNumber2());
numberPicker3.setValue(savedState.getNumber3());
}
@Override
protected void dispatchSaveInstanceState(SparseArray container) {
super.dispatchFreezeSelfOnly(container);
}
@Override
protected void dispatchRestoreInstanceState(SparseArray container) {
super.dispatchThawSelfOnly(container);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment