Android uses parcelable to define model for transitive data

Source: Internet
Author: User

Parcelable data

public class hotelroom implements parcelable {public hotelroom  () { this.adultordernumber = 1;this.roomnumber = 1;this.kidordernumber = 0;} /**  Adult Order Quantity */private int adultordernumber;/**  number of rooms */private int roomnumber;/**   Children's order quantity */private int kidordernumber;/** child age */private int[] childages = null ;p ublic int[] getchildages ()  {return childages;} Public void setchildages (Int[] childages)  {this.childages = childages;} Public int getadultordernumber ()  {return adultordernumber;} Public void setadultordernumber (Int adultordernumber)  {this.adultOrderNumber =  Adultordernumber;} Public int getroomnumber ()  {return roomnumber;} Public void setroomnumber (Int roomnumber)  {this.roomnumber = roomnumber;} Public int getkidordernumber ()  {return kidordernumber;} Public void setkidordernumber (Int kidordernumber)  {this.kidOrderNumber =  Kidordernumber;} @Overridepublic  int describecontents ()  {return 0;} @Overridepublic  void writetoparcel (parcel dest, int flags)  {dest.writeint ( This.adultordernumber);d est.writeint (this.kidordernumber);d est.writeint (This.roomnumber), if (childAges==null) { childages = new int[0]; //Note that this must be handled, otherwise null pointer exception}dest.writeintarray (childages);  } Public static final parcelable.creator 


Android uses parcelable to define model for transitive data

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.