实现parcelable接口中list处理方法


import java.util.ArrayList;
import java.util.List;

import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;

/**
 * 商家分类信息 
 * @author xiaoyi
 *
 * 2015年4月12日
 */
public class Arr_seller_type implements Parcelable{

	private String seller_type;
	private String seller_type_name;
	private String picture;
	private String color;
	private ArrayList<helperPoSort> sub_type;
	public String getSeller_type() {
		return seller_type;
	}
	public void setSeller_type(String seller_type) {
		this.seller_type = seller_type;
	}
	public String getSeller_type_name() {
		return seller_type_name;
	}
	public void setSeller_type_name(String seller_type_name) {
		this.seller_type_name = seller_type_name;
	}
	public String getPicture() {
		return picture;
	}
	public void setPicture(String picture) {
		this.picture = picture;
	}
	public String getColor() {
		return color;
	}
	public void setColor(String color) {
		this.color = color;
	}
	public List<helperPoSort> getSub_type() {
		return sub_type;
	}
	public void setSub_type(ArrayList<helperPoSort> sub_type) {
		this.sub_type = sub_type;
	}
	@Override
	public String toString() {
		return "Arr_seller_type [seller_type=" + seller_type
				+ ", seller_type_name=" + seller_type_name + ", picture="
				+ picture + ", color=" + color + ", sub_type=" + sub_type + "]";
	}
	public Arr_seller_type(String seller_type, String seller_type_name,
			String picture, String color, ArrayList<helperPoSort> sub_type) {
		super();
		this.seller_type = seller_type;
		this.seller_type_name = seller_type_name;
		this.picture = picture;
		this.color = color;
		this.sub_type = sub_type;
	}
	
	public Arr_seller_type() {
		// TODO Auto-generated constructor stub
	}
	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}
	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(seller_type);
		dest.writeString(seller_type_name);
		dest.writeString(color);
		dest.writeString(picture);<span style="color:#ff0000;">
		dest.writeList(sub_type);</span>
	}
	
public static final Parcelable.Creator<Arr_seller_type> CREATOR = new Creator<Arr_seller_type>() {
		
		@Override
		public Arr_seller_type[] newArray(int size) {
			return new Arr_seller_type[size];
		}
		
		@Override
		public Arr_seller_type createFromParcel(Parcel source) {
			Arr_seller_type parcelableHelperPo = new Arr_seller_type();
			parcelableHelperPo.seller_type = source.readString();
			parcelableHelperPo.seller_type_name = source.readString();
			parcelableHelperPo.picture = source.readString();
			parcelableHelperPo.color = source.readString();<span style="color:#ff0000;">
			//<span style="font-family: Arial, Helvetica, sans-serif;">helperPoSort也实现parcelable接口</span>
			parcelableHelperPo.sub_type = new ArrayList<helperPoSort>();
			source.readList(parcelableHelperPo.sub_type, getClass().getClassLoader());</span>
			return parcelableHelperPo;
		}
	};
	
}


  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值