Created
September 20, 2017 09:25
-
-
Save thinkerzhangyan/8acd3e2d0ab97a67cd7dc2f47782eca5 to your computer and use it in GitHub Desktop.
Book.java
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 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