Create a parcelable that contains an array of objects in Android

Source: Internet
Author: User

public class Bill implements parcelable{//order number public int orderid;//original system idpublic int oldid;//Order address public String address;// Order notes public string ext;//order telephone public string mobile;//order user name public string name;//paid amount public double payed;//order time public St Ring date;//Order Total public double total;//required payment public double pay;//store name public string shopname;//store phone public string Shopphone ;//order status, 0 to be determined, 1 determined public int state;//accept this order employee public int staff;//whether delivery, 0 not delivered, 1 delivery public int type;//Cargo public Goods goods[];p        Ublic 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) {Retu        RN new Bill (in);        } @Override Public bill[] NewArray (int size) {return new bill[size]; }    };}

The goods object implements the Parcelable interface

Create a parcelable that contains an array of objects in Android

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.