Save instance state in android compound component From http://www.charlesharley.com/2012/programming/views-saving-instance-state-in-android/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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