Android Implementation Parcelable serialized objects

Source: Internet
Author: User

Package com.sl.pocketbook.bean;import android.os.parcel;import android.os.parcelable;import  android.os.Parcelable.Creator;/** *  Brands  *  *  @author  sxn *   */public class ProductBrandBean implements Parcelable {     /**     * id     */    private  int id;    /**     *  Quantity       */    private int conunt;    /**      * icon     */    private String  urlicon;    /**     *  name      */     private String brandName;    public static  Final parcelable.creator<producTbrandbean> creator = new creator<productbrandbean> ()  {          @Override         public  Productbrandbean createfromparcel (Parcel source)  {             // TODO Auto-generated method stub             //  must read the data in the order in which the member variable is declared, or there will be an error getting data              productbrandbean p = new productbrandbean ( );             p.setid (Source.readInt ());             p.setconunt (Source.readInt ());             p.seturlicon (Source.readstring ());              p.setbrandname (Source.readstring ());             return p;        }          @Override         public productbrandbean[ ] newarray (int size)  {            / / todo auto-generated method stub             return new ProductBrandBean[size];         }    };    public string getbrandname ()  {         return brandName;    }     Public void setbrandname (String brandname)  {         this.brandname =&Nbsp;brandname;    }    public productbrandbean ()  {     }    public int getid ()  {         return id;    }    public void setid ( Int id)  {        this.id = id;     }    public int getconunt ()  {         return conunt;    }    public void  Setconunt (Int conunt)  {        this.conunt =  Conunt;    }    public string geturlicon ()  {         return urlIcon;    }     public void seturlicon (StrinG urlicon)  {        this.urlIcon = urlIcon;     }     @Override     public int  Describecontents ()  {        // todo auto-generated  method stub        return 0;    }      @Override     public void writetoparcel (Parcel dest,  int flags)  {        // 1. The data must be encapsulated in the order in which the member variable is declared. Otherwise there will be an error getting data         // 2. Serializing Objects          dest.writeint (ID);         dest.writeint (Conunt);         dest.writestring (Urlicon);         dest.writestring (brandname);     }} 




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.