首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

Activity 间传送对象, 采用Parcelable

2012-09-06 
Activity 间传递对象, 采用ParcelableActivity 间传递对象, 采用Parcelable. 例子如下:??public class For

Activity 间传递对象, 采用Parcelable

Activity 间传递对象, 采用Parcelable. 例子如下:?

?

public class FormatEntity implements Parcelable {

public String mAccount;

public String mCode;

public int limitAmount;

public String imeis;

public PrivateFormatEntity() {

super();

}

public PrivateFormatEntity(Parcel source) {

mAccount = source.readString();

mCode = source.readString();

limitAmount = source.readInt();

imeis = source.readString();

}

@Override

public int describeContents() {

return 0;

}

@Override

public void writeToParcel(Parcel dest, int flags) {

dest.writeString(mAccount);

dest.writeString(mCode);

dest.writeInt(limitAmount);

dest.writeString(imeis);

}

public static final Parcelable.Creator<PrivateFormatEntity> CREATOR = new Creator<PrivateFormatEntity>() {

@Override

public PrivateFormatEntity[] newArray(int size) {

return new PrivateFormatEntity[size];

}

@Override

public PrivateFormatEntity createFromParcel(Parcel source) {

return new PrivateFormatEntity(source);

}

};

}

发送:?

?

FormatEntity ?youFormat = new FormatEntity();

it.putExtra("yourname", youFormat);

获取:

it.getParcelableExtra("yourname");

热点排行