import java.util.ArrayList;
import java.util.List;
import android.os.Parcel;
import android.os.Parcelable;
public class Reasons implements Parcelable {
private List<List<String>> exchangeReasons;
private List<String> exchangeReasonGroupsName;
private int size;
public Reasons(){
// do init
exchangeReasonGroupsName = new ArrayList<String>();
exchangeReasons = new ArrayList<List<String>>();
}
private Reasons(Parcel in){
exchangeReasonGroupsName = new ArrayList<String>();
exchangeReasons = new ArrayList<List<String>>();
readFromParcel(in);
}
public void setExchangeReasons(List<List<String>> exchangeReasons) {
this.exchangeReasons = exchangeReasons;
size = exchangeReasons.size();
}
public List<List<String>> getExchangeReasons() {
return exchangeReasons;
}
public void setExchangeReasonGroupsName(List<String> exchangeReasonGroupsName) {
this.exchangeReasonGroupsName = exchangeReasonGroupsName;
}
public List<String> getExchangeReasonGroupsName() {
return exchangeReasonGroupsName;
}
public static final Parcelable.Creator<Reasons> CREATOR = new Creator<Reasons>() {
public Reasons createFromParcel(Parcel source) {
return new Reasons(source);
}
public Reasons[] newArray(int size) {
return new Reasons[size];
}
};
/* (non-Javadoc)
* @see android.os.Parcelable#describeContents()
*/
@Override
public int describeContents() {
// TODO Auto-generated method stub
return 0;
}
/* (non-Javadoc)
* @see android.os.Parcelable#writeToParcel(android.os.Parcel, int)
*/
@Override
public void writeToParcel(Parcel dest, int flags) {
// TODO Auto-generated method stub
dest.writeStringList(exchangeReasonGroupsName);
dest.writeInt(size);
for(int i=0;i<size;i++){
dest.writeStringList(exchangeReasons.get(i));
}
}
private void readFromParcel(Parcel in){
exchangeReasons = new ArrayList<List<String>>();
in.readStringList(exchangeReasonGroupsName);
size = in.readInt();
for(int i=0;i<size;i++){
List<String> tmp = new ArrayList<String>();
in.readStringList(tmp);
exchangeReasons.add(tmp);
}
}
}
getIntent().getParcelableExtra() 获取传递的对象