<small id='sqHv7'></small><noframes id='sqHv7'>

      <bdo id='sqHv7'></bdo><ul id='sqHv7'></ul>
    <legend id='sqHv7'><style id='sqHv7'><dir id='sqHv7'><q id='sqHv7'></q></dir></style></legend>
    <tfoot id='sqHv7'></tfoot>
      <i id='sqHv7'><tr id='sqHv7'><dt id='sqHv7'><q id='sqHv7'><span id='sqHv7'><b id='sqHv7'><form id='sqHv7'><ins id='sqHv7'></ins><ul id='sqHv7'></ul><sub id='sqHv7'></sub></form><legend id='sqHv7'></legend><bdo id='sqHv7'><pre id='sqHv7'><center id='sqHv7'></center></pre></bdo></b><th id='sqHv7'></th></span></q></dt></tr></i><div id='sqHv7'><tfoot id='sqHv7'></tfoot><dl id='sqHv7'><fieldset id='sqHv7'></fieldset></dl></div>

        Android Parcelable - 使用通用数据类型读取/写入数据到 Parcel

        Android Parcelable - read/write data to Parcel using generic data type(Android Parcelable - 使用通用数据类型读取/写入数据到 Parcel)
          <bdo id='xblpD'></bdo><ul id='xblpD'></ul>

          • <tfoot id='xblpD'></tfoot>
              <tbody id='xblpD'></tbody>
            1. <legend id='xblpD'><style id='xblpD'><dir id='xblpD'><q id='xblpD'></q></dir></style></legend>

              <i id='xblpD'><tr id='xblpD'><dt id='xblpD'><q id='xblpD'><span id='xblpD'><b id='xblpD'><form id='xblpD'><ins id='xblpD'></ins><ul id='xblpD'></ul><sub id='xblpD'></sub></form><legend id='xblpD'></legend><bdo id='xblpD'><pre id='xblpD'><center id='xblpD'></center></pre></bdo></b><th id='xblpD'></th></span></q></dt></tr></i><div id='xblpD'><tfoot id='xblpD'></tfoot><dl id='xblpD'><fieldset id='xblpD'></fieldset></dl></div>

                <small id='xblpD'></small><noframes id='xblpD'>

                  本文介绍了Android Parcelable - 使用通用数据类型读取/写入数据到 Parcel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  How can i implement to write my Set < ArrayList < ? > > to my Parcel using generic data type ?

                  Here is my code..

                          dest.writeList(getArrTRA());
                          dest.writeList(getArrTSAC());
                          dest.write???(getArrListSet()); //how can i write my Set<ArrayList<?
                  
                  
                  public Set<ArrayList<?>> getArrListSet() {
                          return arrSetOfPaymentMode;
                      }
                  

                  解决方案

                  public class ImageContainer implements Serializable, Parcelable  {
                  /**
                   * 
                   */
                  private static final long serialVersionUID = 1L;
                  
                  public ImageContainer() {
                      // TODO Auto-generated constructor stub
                  }
                  public ImageContainer(Parcel in) {
                      // TODO Auto-generated constructor stub
                      readFromParcel(in);
                  }
                  
                  
                  /**
                   * custom images in this article
                   */
                  @SerializedName("Image")
                  ArrayList<ImageCls> alCustomImages=new ArrayList<ImageCls>();
                  
                  public ArrayList<ImageCls> getAlCustomImages() {
                      return alCustomImages;
                  }
                  public void setAlCustomImages(ArrayList<ImageCls> alCustomImages) {
                      this.alCustomImages = alCustomImages;
                  }
                  @Override
                  public int describeContents() {
                      // TODO Auto-generated method stub
                      return 0;
                  }
                  @Override
                  public void writeToParcel(Parcel dest, int flags) {
                      // TODO Auto-generated method stub
                      dest.writeList(alCustomImages);
                  }
                  @SuppressWarnings("unchecked")
                  private void readFromParcel(Parcel in) {
                      // TODO Auto-generated method stub
                      this.alCustomImages = in.readArrayList(ImageCls.class.getClassLoader());
                  }
                  
                  @SuppressWarnings("rawtypes")
                  public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
                      public ImageContainer createFromParcel(Parcel in) {
                          return new ImageContainer(in);
                      }
                  
                      public ImageContainer[] newArray(int size) {
                          return new ImageContainer[size];
                      }
                  };
                  }
                  

                  your class should implement Parcelable. An example is in above code.

                  Your issue is you are trying to read/write generic data type to the Parcel. But it is not possible to read/write generic data type in parcel. Read more how to use Parcelable here and Parcel here

                  这篇关于Android Parcelable - 使用通用数据类型读取/写入数据到 Parcel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Compiling C++ for the JVM(为 JVM 编译 C++)
                  Compile to java bytecode (without using Java)(编译成java字节码(不使用Java))
                  How to drive C#, C++ or Java compiler to compute 1+2+3+...+1000 at compile time?(如何在编译时驱动 C#、C++ 或 Java 编译器计算 1+2+3+...+1000?)
                  Java ClassLoader: load same class twice(Java ClassLoader:两次加载相同的类)
                  How to debug .class files in ECLIPSE?(如何在 ECLIPSE 中调试 .class 文件?)
                  Java quot;The blank final field may not have been initializedquot; Anonymous Interface vs Lambda Expression(Java“可能尚未初始化空白的最终字段匿名接口与 Lambda 表达式)

                    <small id='HgJpR'></small><noframes id='HgJpR'>

                    • <tfoot id='HgJpR'></tfoot>
                            <tbody id='HgJpR'></tbody>
                          <legend id='HgJpR'><style id='HgJpR'><dir id='HgJpR'><q id='HgJpR'></q></dir></style></legend>
                          <i id='HgJpR'><tr id='HgJpR'><dt id='HgJpR'><q id='HgJpR'><span id='HgJpR'><b id='HgJpR'><form id='HgJpR'><ins id='HgJpR'></ins><ul id='HgJpR'></ul><sub id='HgJpR'></sub></form><legend id='HgJpR'></legend><bdo id='HgJpR'><pre id='HgJpR'><center id='HgJpR'></center></pre></bdo></b><th id='HgJpR'></th></span></q></dt></tr></i><div id='HgJpR'><tfoot id='HgJpR'></tfoot><dl id='HgJpR'><fieldset id='HgJpR'></fieldset></dl></div>
                            <bdo id='HgJpR'></bdo><ul id='HgJpR'></ul>