標籤:android parcelable
public class Bill implements Parcelable{// 訂單號public int orderid;// 原系統idpublic int oldid;// 訂單地址public String address;// 訂單備忘public String ext;// 訂單電話public String mobile;// 訂單使用者姓名public String name;// 已支付金額public double payed;// 訂單時間public String date;// 訂單總價public double total;// 所需付款public double pay;// 店鋪名稱public String shopname;// 店鋪電話public String shopphone;// 訂單狀態,0待確定,1已確定public int state;// 接受此訂單的員工public int staff;//是否送達,0未送達,1送達public int type;// 貨物public Goods goods[];public Bill() {// TODO Auto-generated constructor stub} protected Bill(Parcel in) { orderid = in.readInt(); oldid = in.readInt(); address = in.readString(); ext = in.readString(); mobile = in.readString(); name = in.readString(); payed = in.readDouble(); date = in.readString(); total = in.readDouble(); pay = in.readDouble(); shopname = in.readString(); shopphone = in.readString(); state = in.readInt(); staff = in.readInt(); type = in.readInt(); Parcelable[] parcelables = in.readParcelableArray(Goods.class.getClassLoader()); if (parcelables != null) {goods = Arrays.copyOf(parcelables, parcelables.length, Goods[].class);} } @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel dest, int flags) { dest.writeInt(orderid); dest.writeInt(oldid); dest.writeString(address); dest.writeString(ext); dest.writeString(mobile); dest.writeString(name); dest.writeDouble(payed); dest.writeString(date); dest.writeDouble(total); dest.writeDouble(pay); dest.writeString(shopname); dest.writeString(shopphone); dest.writeInt(state); dest.writeInt(staff); dest.writeInt(type); dest.writeParcelableArray(goods, flags); } @SuppressWarnings("unused") public static final Parcelable.Creator<Bill> CREATOR = new Parcelable.Creator<Bill>() { @Override public Bill createFromParcel(Parcel in) { return new Bill(in); } @Override public Bill[] newArray(int size) { return new Bill[size]; } };}
Goods對象實現了Parcelable介面
在android中建立包含對象數組的Parcelable