zoukankan      html  css  js  c++  java
  • Parcel

    android提供了一种新的类型:Parcel。本类被用作封装数据的容器,封装后的数据可以通过Intent或IPC传递。 除了基本类型以
    外,只有实现了Parcelable接口的类才能被放入Parcel中。
     
    Parcelable实现要点:需要实现三个东西
    1)writeToParcel 方法。该方法将类的数据写入外部提供的Parcel中.声明如下:
    writeToParcel (Parcel dest, int flags) 具体参数含义见javadoc
    2)describeContents方法。没搞懂有什么用,反正直接返回0也可以
    3)静态的Parcelable.Creator接口,本接口有两个方法:
    createFromParcel(Parcel in) 实现从in中创建出类的实例的功能
    newArray(int size) 创建一个类型为T,长度为size的数组,仅一句话(return new T[size])即可。估计本方法是供外部类反序列化本类数组使用。
  • 相关阅读:
    ubuntu上安装boost库
    boost array使用
    2017新年总结
    qt 设置等待事件
    vs下 qt源码调试
    使用记事本创建Web服务(WebService)
    司以类聚,人以群分
    附件上传
    DES 加密解密
    工作总结-js插件
  • 原文地址:https://www.cnblogs.com/liubingna/p/3383929.html
Copyright © 2011-2022 走看看