import java.io.Serializable;
import java.text.DecimalFormat; import android.os.Parcel;
import android.os.Parcelable; /**
* 代金券/团购实体类
* @author huqiang
*
*/
public class CouponEntity implements Parcelable{
/**
* shop_id
*/
public String shop_id ;
/**
* 店铺名称
*/
public String shop_name ;
/**
* 代金券id
*/
public String coupon_id ;
/**
* 代金券编号
*/
public String coupon_no ;
/**
* 优惠券标题
*/
public String coupon_name ;
/**
* 优惠券类型 1:代金券 2:团购券
*/
public int coupon_type ; public double getCoupon_sale_amount() {
return coupon_sale_amount;
}
public void setCoupon_sale_amount(double coupon_sale_amount) {
DecimalFormat df = new DecimalFormat("#.00");
this.coupon_sale_amount = Double.parseDouble(df.format(coupon_sale_amount));
}
/**
* 允许2位小数
* @return
*/
public double getCoupon_vaules_amount() {
return coupon_vaules_amount;
}
public void setCoupon_vaules_amount(double coupon_vaules_amount) {
DecimalFormat df = new DecimalFormat("#.00");
this.coupon_vaules_amount = Double.parseDouble(df.format(coupon_vaules_amount));
}
/*---------------------实现Parcelable序列化---------------------------------*/
public CouponEntity(Parcel in)
{
shop_id = in.readString();
shop_name = in.readString();
coupon_id = in.readString();
coupon_no = in.readString();
coupon_type = in.readInt();
}
public static final Parcelable.Creator<CouponEntity> CREATOR = new Parcelable.Creator<CouponEntity>() {
public CouponEntity createFromParcel(Parcel in) {
return new CouponEntity(in);
} public CouponEntity[] newArray(int size) {
return new CouponEntity[size];
}
}; @Override
public int describeContents() {
// 内容描述,返回0即可
return 0;
}
@Override
public void writeToParcel(Parcel out, int arg1) {
out.writeString(shop_id);
out.writeString(shop_name);
out.writeString(coupon_id);
out.writeString(coupon_no);
out.writeInt(coupon_type);
} }

实现Parcelable序列化步骤
1、implements implements Parcelable
2、

    /*---------------------实现Parcelable序列化---------------------------------*/
public CouponEntity(Parcel in)
{
shop_id = in.readString();
shop_name = in.readString();
coupon_id = in.readString();
coupon_no = in.readString();
coupon_type = in.readInt();
}
public static final Parcelable.Creator<CouponEntity> CREATOR = new Parcelable.Creator<CouponEntity>() {
public CouponEntity createFromParcel(Parcel in) {
return new CouponEntity(in);
} public CouponEntity[] newArray(int size) {
return new CouponEntity[size];
}
}; @Override
public int describeContents() {
// 内容描述,返回0即可
return 0;
}
@Override
public void writeToParcel(Parcel out, int arg1) {
out.writeString(shop_id);
out.writeString(shop_name);
out.writeString(coupon_id);
out.writeString(coupon_no);
out.writeInt(coupon_type);
}

android中实现Parcelable序列化步骤的更多相关文章

  1. Android中的Parcelable接口和Serializable使用方法和差别

    Parcelable接口: Interface for classes whose instances can be written to and restored from a Parcel. Cl ...

  2. Android中使用Parcelable

    今天 在两个Activity之间传集合类型数据,看了一下,要用Parcelable 所以就看一下东西: 下面一段话是复制网友的. Android序列化对象主要有两种方法,实现Serializable接 ...

  3. Android中SharedPreferences和序列化结合保存对象数据

    前言: 最近在做用户注册的时候,遇到了需要填写很多表单数据,不可能在一页把所有的数据都展示完全,因此采用了分页的方式,由于在用户填写数据数据之后我们需要对用户填写的数据进行暂时的记录的,当用户会到此页 ...

  4. Android中ListView的使用步骤

    第一步:  首先,在 布局文件中,声明listView控件. <ListView android:id="@+id/lv" android:layout_width=&quo ...

  5. 在android中进行单元测试的步骤

    若不知道怎么配上面两个参数 

  6. Android中Parcelable序列化总结

    在使用Parcelable对android中数据的序列化操作还是比较有用的,有人做过通过对比Serializable和Parcelable在android中序列化操作对象的速度比对,大概Parcela ...

  7. Android中Serializable和Parcelable序列化对象详解

    学习内容: 1.序列化的目的 2.Android中序列化的两种方式 3.Parcelable与Serializable的性能比较 4.Android中如何使用Parcelable进行序列化操作 5.P ...

  8. Android中Parcelable接口

    1. Parcelable接口 Interface for classes whose instances can be written to and restored from a Parcel. ...

  9. 浅谈Android中Serializable和Parcelable使用区别

    版权声明:本文出自汪磊的博客,转载请务必注明出处. 一.概述 Android开发的时候,我们时长遇到传递对象的需求,但是我们无法将对象的引用传给Activity或者Fragment,我们需要将这些对象 ...

随机推荐

  1. 【Quote】What is Mono

    What is Mono Mono is a software platform designed to allow developers to easily create cross platfor ...

  2. java识别验证码

    所需资源下载链接(资源免费,重在分享) Tesseract:http://download.csdn.net/detail/chenyangqi/9190667 jai_imageio-1.1-alp ...

  3. Part 10 Stored procedures in sql server

    Stored procedures in sql server Stored procedures with output parameters Stored procedure output par ...

  4. Android渲染机制和丢帧分析

    http://blog.csdn.net/bd_zengxinxin/article/details/52525781 自己编写App的时候,有时会感觉界面卡顿,尤其是自定义View的时候,大多数是因 ...

  5. pip在windows域下使用代理安装package方法

    首先说明下,本人在公司使用windows域账户代理上网,用pip在线安装package 返回ProxyError,类似Tunnel connection failed: 407 authenticat ...

  6. 【SNMP】SNMP概述

    SNMP概述 SNMP(Simple Network Management Protocol,简单网络管理协议)是目前UDP/IP网络中应用最为广泛的网络管理协议,它提供了一个管理框架来监控和维护互联 ...

  7. UI1_Calayer

    // // ViewController.m // UI1_Calayer // // Created by zhangxueming on 15/7/2. // Copyright (c) 2015 ...

  8. OC4_遵守多个协议

    // // Calulator.h // OC4_遵守多个协议 // // Created by zhangxueming on 15/6/24. // Copyright (c) 2015年 zha ...

  9. 数据库设计(字段)中的char、varchar、text和nchar、nvarchar、ntext的区别

    char.varchar.text和nchar.nvarchar.ntext的区别 1.CHAR.CHAR存储定长数据很方便,CHAR字段上的索引效率级高,比如定义char(10),那么不论你存储的数 ...

  10. 通过Driver获取数据库连接

    先看一下文件,在当前包下有一个properties配置文件,在根目录下有一个lib文件夹,里面放的是mySql的驱动jar包 Driver :是一个接口,数据库厂商必须提供实现的接口,能从其中获取数据 ...