在android中建立包含對象數組的Parcelable

來源:互聯網
上載者:User

標籤: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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.