Writing arrays of Parcelables to a Parcel in Android

后端 未结 3 1805
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-12 21:31

I\'m trying to write an array of objects that implement Parcelable into a Parcel using writeParcelableArray.

The objects I\'m trying to write are defined (as you\'

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-12 22:25

    It turns out it just wanted me to build an array of Parcelables. To use the example from the question:

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        Parcelable[] a;
        /* 
            some stuff to populate "a" with Arrival 
            objects (which implements Parcelable) 
        */
        dest.writeParcelableArray(a, 0);
    }
    

提交回复
热议问题