Android Parcelable 序列化特殊格式

Boolean 类型

this.myBoolean = in.readByte() != 0;     //myBoolean == true if byte != 0  
dest.writeByte((byte) (this.myBoolean ? 1 : 0));     //if myBoolean == true, byte == 1  

Date 类型

 this.myDate = new Date(in.readLong());

 parcel.writeLong(this.myDate.getTime());

ArrayList 类型

 this.myArrayList = new ArrayList<>();
 in.readList(this.myArrayList, People.class.getClassLoader());
 parcel.writeList(this.myArrayList);




 
 

猜你喜欢

转载自blog.csdn.net/dashujua/article/details/80775418