写物体包裹在writeToParcel方法 [英] Write object in Parcel in writeToParcel method
本文介绍了写物体包裹在writeToParcel方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
喜队友我有一个类必须实现Parcelable允许把这种新型的捆绑
我班有2个属性
私人诠释PID;
私有对象的数据;
我要实现writeToParcel方法:但我不知道写的属性数据
@覆盖
公共无效writeToParcel(DEST包裹,INT标志){
dest.writeInt(PID);
DEST?}
解决方案
看看的的 Parcelable的文档。它显示了添加和retreiving原始值的例子。
如果你想添加对象Parcelable要添加必须实现Parcelable或序列化对象。
hi mate i have a class that must to implement Parcelable to allow to put this new type in a bundle My class have 2 attribute private int pid; private Object data; i have to implement writeToParcel method : but i dont know to write the attribute data
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(pid);
dest.?
}
解决方案
Take a look at the documentation of Parcelable. It shows an example for adding and retreiving primitive values.
If you want to add Objects to a Parcelable the Object you want to add must implement either Parcelable or Serializable.
这篇关于写物体包裹在writeToParcel方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文