Created
July 6, 2019 11:12
-
-
Save matthew-carroll/62a0e557a19c2d3601a8366a6c7ec8d1 to your computer and use it in GitHub Desktop.
Implements Parcelable in a custom View in Android (3/4).
This file contains hidden or 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
public class MyView extends View { | |
private static class SavedState extends BaseSavedState { | |
String name; | |
int index; | |
SavedState(Parcelable superState) { | |
super(superState); | |
} | |
private SavedState(Parcel in) { | |
super(in); | |
name = in.readString(); | |
index = in.readInt(); | |
} | |
@Override | |
public void writeToParcel(Parcel out, int flags) { | |
super.writeToParcel(out, flags); | |
out.writeString(name); | |
out.writeInt(index); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment