1.
Importjava.util.List;ImportAndroid.os.Parcel;Importandroid.os.Parcelable;/*** 1) Writetoparcel method. This method writes the data of the class to an externally supplied parcel. * 2) Describecontents method. return directly to 0. * 3) Static parcelable.creator<t> interface, this interface has two methods: * Createfromparcel (Parcel in) implements the function of creating an instance of the class from in. * NewArray (int size) creates an array of type T, length of size, returnnew t[size]; This method is used by the outer class to deserialize the array of this class. * * @authorJL*/ Public classViewPointImplementsparcelable {PrivateString V_name; PrivateList<string>v_picture; PrivateList<string>v_description; /*** The sequence of read in this step should be consistent with the order of Writetoparcel *@paramParcel*/ PrivateViewPoint (Parcel Parcel) {//TODO auto-generated Constructor stubV_name=parcel.readstring (); V_description=parcel.readarraylist (List.class. getClassLoader ()); V_picture=parcel.readarraylist (List.class. getClassLoader ()); //list<string>:p arcel.readarraylist (List.class.getClassLoader ())//map<string, string>:p arcel.readhashmap (Map.class.getClassLoader ())//list<school>:p arcel.readarraylist (School.class.getClassLoader ())//School:(School) parcel.readparcelable (School.class.getClassLoader ()) } PublicViewPoint () {//TODO auto-generated Constructor stub } Public Static FinalParcelable.creator<viewpoint> creator=NewParcelable.creator<viewpoint>() {@Override PublicViewPoint Createfromparcel (Parcel source) {//TODO auto-generated Method Stub return NewViewPoint (source); } @Override PublicViewpoint[] NewArray (intsize) { //TODO auto-generated Method Stub return NewViewpoint[size]; } }; PublicString Getv_name () {returnV_name; } Public voidsetv_name (String v_name) { This. V_name =V_name; } PublicList<string>getv_picture () {returnv_picture; } Public voidSetv_picture (list<string>v_picture) { This. V_picture =v_picture; } PublicList<string>getv_description () {returnv_description; } Public voidSetv_description (list<string>v_description) { This. v_description =v_description; } @Override Public intdescribecontents () {//TODO auto-generated Method Stub return0; } @Override Public voidWritetoparcel (Parcel dest,intflags) { //TODO auto-generated Method Stub//writes the data to be serialized to the parcel object//list is written: Writelist//school:writeparcelable (Schoolinfo, arg1), and School itself is a Parcelable objectdest.writestring (v_name); Dest.writelist (v_description); Dest.writelist (v_picture); }}
Done