Skip to content

Instantly share code, notes, and snippets.

@matthew-carroll
Last active July 6, 2019 11:18
Show Gist options
  • Save matthew-carroll/7536e024952e5cb15b4845d47cf44816 to your computer and use it in GitHub Desktop.
Save matthew-carroll/7536e024952e5cb15b4845d47cf44816 to your computer and use it in GitHub Desktop.
Implements onSaveInstanceState in a custom View in Android.
@Override
public Parcelable onSaveInstanceState() {
// Obtain any state that our super class wants to save.
Parcelable superState = super.onSaveInstanceState();
// Wrap our super class's state with our own.
SavedState myState = new SavedState(superState);
myState.name = this.name;
myState.index = this.index;
// Return our state along with our super class's state.
return myState;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment