(android-001) Non-basic type implementation parcelable use

Source: Internet
Author: User

Entity Bean

package org.mo.common.util.entity;import java.util.date;import android.os.parcel;import  android.os.parcelable;/** *  *  @author  moziqi *  */public class  BeanDemo implements Parcelable {private Integer id;private String  Name;private date createtime;public integer getid ()  {return id;} Public void setid (Integer id)  {this.id = id;} Public string getname ()  {return name;} Public void setname (String name)  {this.name = name;} Public date getcreatetime ()  {return createtime;} Public void setcreatetime (Date createtime)  {this.createtime = createtime;} @Overridepublic  string tostring ()  {return  "beandemo [id="  + id +  ",  name="  + name +  ",  createtime=" + createtime +  "]";} @Overridepublic  int describecontents ()  {return 0;} @Overridepublic  void writetoparcel (parcel dest, int flags)  {//  Serialize Dest.writeint (ID);d est.writestring (name);d est.writeserializable (createtime);} public static final parcelable.creator<beandemo> creator = new  Creator<beandemo> ()  {@Overridepublic  beandemo[] newarray (int size)  {return  new beandemo[size];} @Overridepublic  beandemo createfromparcel (Parcel source)  {//  Online said must be written in order to write//  The data must be read in the order in which the member variable is declared, otherwise there will be an error in getting the data//  deserialization Beandemo beandemo = new beandemo (); Beandemo.setid ( Source.readint ()); Beandemo.setname (Source.readstring ());//  View the parent class of date is Serializablebeandemo.setcreatetime (( Date)  source.readserializable ()); return beandemo;}};}

Corresponds to a table class

Package Org.mo.common.util.table;public class BaseTable {public final static String ID = "_id";}

//

Package Org.mo.common.util.table;public class Beandemotable extends BaseTable {public final static String name = "Name";p u Blic final static String create_time = "Create_time";}

(android-001) Non-basic type implementation parcelable use

Related Article

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.