Directly on the code: the comments are written very clearly.
public class Entry implements parcelable{
public int UserID;
Public String username;
public Boolean Ismale;
Public book book;//serialization objects can nest serialized objects, provided that objects of 2 classes are
Returns 0 in almost all cases, regardless
@Override
public int describecontents () {
return 0;
}
Serializing objects, writing objects to the sequence Number data structure
Flags: Most cases are 0
@Override
public void Writetoparcel (Parcel out, int flags) {
Out.writeint (UserID);
Out.writestring (username);
Out.writeint (Ismale 1:0);
Out.writeparcelable (book, 0);
Out.writelist (list) or serial number list and map, provided that the data in the list and map are serial numbers
Out.writemap (MAP);
}
Public Entry (int userid,string Username,boolean ismale) {
This.userid = UserID;
This.username = Username;
This.ismale = Ismale;
}
Deserialization
public static final parcelable.creator<entry> Creator = new Creator<entry> () {
Creates an array of original objects of the specified length
@Override
Public entry[] NewArray (int size) {
TODO auto-generated Method Stub
return new Entry[size];
}
Create the original object from the object after the serial number
@Override
Public Entry Createfromparcel (Parcel source) {
TODO auto-generated Method Stub
return new Entry (source);
}
};
Create the original object from the object after the serial number
Private Entry (Parcel in) {
UserID = In.readint ();
Username = in.readstring ();
Ismale = in.readint () = = 1;
In.readparcelable (Thread.CurrentThread (). Getcontextclassloader ());
}
}
Android very detailed serialization process parcelable