<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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)

                    <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>