Created
June 12, 2016 03:52
-
-
Save shau-lok/a8a4c46f96f0d61bab70adbb374e3def to your computer and use it in GitHub Desktop.
Parcelable sample
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
public class MyParcelable implements Parcelable { | |
private int mData; | |
public int describeContents() { | |
return 0; | |
} | |
public void writeToParcel(Parcel out, int flags) { | |
out.writeInt(mData); | |
} | |
public static final Parcelable.Creator<MyParcelable> CREATOR | |
= new Parcelable.Creator<MyParcelable>() { | |
public MyParcelable createFromParcel(Parcel in) { | |
return new MyParcelable(in); | |
} | |
public MyParcelable[] newArray(int size) { | |
return new MyParcelable[size]; | |
} | |
}; | |
private MyParcelable(Parcel in) { | |
mData = in.readInt(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment