Parcelable
来源:互联网 发布:天敏智能网络电视盒 编辑:程序博客网 时间:2024/05/17 02:19
实现了Parcelable接口的类,可以通过Intent.putExtra(String name, Parcelable value)这个方法传递其对象。
android.os.Parcelable
Interface for classes whose instances can be written to and restored from a Parcel. Classes
implementing the Parcelable interface must also have a static field called CREATOR, which is an
object implementing the Parcelable.Creator interface.
A typical implementation of Parcelable is:
public class MyParcelable implements Parcelable { private int mData; public int describeContents() { return 0; } public void writeToParcel(Parcel out, int flags) { out.writeInt(mData); } public static final Parcelable.Creator<MyParcelable> CREATOR = new Parcelable.Creator<MyParcelable>() { public MyParcelable createFromParcel(Parcel in) { return new MyParcelable(in); } public MyParcelable[] newArray(int size) { return new MyParcelable[size]; } }; private MyParcelable(Parcel in) { mData = in.readInt(); } }
MyParcelable demo
08-24 23:20:22.161: D/wzf(1893): MyParcelable
08-24 23:20:22.161: D/wzf(1893): writeToParcel
08-24 23:20:22.331: D/wzf(1893): createFromParcel
08-24 23:20:22.331: D/wzf(1893): private MyParcelable
08-24 23:20:22.331: D/wzf(1893): getData
08-24 23:20:22.331: D/wzf(1893): getString
0 0
- Parcelable
- Parcelable
- Parcelable
- Parcelable
- Parcelable
- Parcelable
- Parcelable
- Parcelable
- Parcelable
- Parcelable
- Parcelable
- parcelable
- Parcelable
- Parcelable
- Parcelable
- Parcelable
- Parcelable
- Parcelable
- WordToPdf,word转pdf
- 计算机与抽象
- 解决Binary XML file line #6: : Error inflating class <unknown> 的问题
- 花生壳远程控制桌面
- bestcode#6—1003 HDU 4983 Goffi and GCD 【欧拉函数】
- Parcelable
- Android硬件加速的一些问题和错误
- CAS实现单点登录(SSO)经典完整教程
- 微博营销事件背后的真与假
- Could not calculate build plan: Plugin org.apache.maven.plugins:maven-resources-plugin:2.5 or one of
- 大小端、网络字节序问题
- hdoj.1405 The Last Practice 20140825
- Machine Learning—The k-means clustering algorithm
- 上海Android培训学习之Android多媒体开发