comment implémenter correctement Parcelable avec une ArrayList<Parcelable>?

Je vais avoir du mal à faire ma classe Parcelable. Le problème est que je suis en train d'écrire à la parcelle, un membre de la classe qui est un ArrayList<Parcelable> objet. Le ArrayList est Serializable, et les objets (ZigBeeDev) dans la liste sont Parcelable.

Voici le code correspondant:

package com.gnychis.coexisyst;
import java.util.ArrayList;
import java.util.Iterator;
import android.os.Parcel;
import android.os.Parcelable;
public class ZigBeeNetwork implements Parcelable {
public String _mac;             //the source address (of the coordinator?)
public String _pan;             //the network address
public int _band;               //the channel
ArrayList<Integer> _lqis;       //link quality indicators (to all devices?)
ArrayList<ZigBeeDev> _devices;  //the devices in the network
public void writeToParcel(Parcel out, int flags) {
out.writeString(_mac);
out.writeString(_pan);
out.writeInt(_band);
out.writeSerializable(_lqis);
out.writeParcelable(_devices, 0);  //help here
}
private ZigBeeNetwork(Parcel in) {
_mac = in.readString();
_pan = in.readString();
_band = in.readInt();
_lqis = (ArrayList<Integer>) in.readSerializable();
_devices = in.readParcelable(ZigBeeDev.class.getClassLoader());  //help here
}
public int describeContents() {
return this.hashCode();
}
public static final Parcelable.Creator<ZigBeeNetwork> CREATOR = 
new Parcelable.Creator<ZigBeeNetwork>() {
public ZigBeeNetwork createFromParcel(Parcel in) {
return new ZigBeeNetwork(in);
}
public ZigBeeNetwork[] newArray(int size) {
return new ZigBeeNetwork[size];
}
};
//...
}

J'ai marqué deux spots "//de l'aide ici" pour comprendre comment écrire correctement à la parcelle, et la façon de le reconstruire. Si ZigBeeDev est Parcelable (testé correctement), comment puis-je faire cela correctement?

InformationsquelleAutor gnychis | 2011-08-12