<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

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

                  上一篇:SortedSet、数组、可序列化的序列化问题 下一篇:在java中将列表转换为逗号分隔字符串的最佳方法

                  相关文章

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

                  1. <tfoot id='HgJpR'></tfoot>
                    1. <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>