Skip to content

Instantly share code, notes, and snippets.

@thinkerzhangyan
Created September 20, 2017 09:25
Show Gist options
  • Save thinkerzhangyan/8acd3e2d0ab97a67cd7dc2f47782eca5 to your computer and use it in GitHub Desktop.
Save thinkerzhangyan/8acd3e2d0ab97a67cd7dc2f47782eca5 to your computer and use it in GitHub Desktop.
Book.java
public class Book implements Parcelable {
public int bookId;
public String bookName;
public Book() {
}
public Book(int bookId, String bookName) {
this.bookId = bookId;
this.bookName = bookName;
}
public int describeContents() {
return 0;
}
public void writeToParcel(Parcel out, int flags) {
out.writeInt(bookId);
out.writeString(bookName);
}
public static final Creator<Book> CREATOR = new Creator<Book>() {
public Book createFromParcel(Parcel in) {
return new Book(in);
}
public Book[] newArray(int size) {
return new Book[size];
}
};
private Book(Parcel in) {
bookId = in.readInt();
bookName = in.readString();
}
@Override
public String toString() {
return String.format("[bookId:%s, bookName:%s]", bookId, bookName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment