我有一个类是 Parcelable 并且有一些字段。其中一个字段是 MarkerOptions,我正在尝试找出如何读写这些 MarkerOptions...
我知道MarkerOptions类是 Parcelable,但我不知道如何从另一个类中读取和写入它......
假设我有这门课:。
public class Foo implements Parcelable {
private MarkerOptions markerOptions;
private String someField;
public Foo() {}
public Foo(Parcel in) {
this.markerOptions = in.readParcelable(MarkerOptions.class.getClassLoader());
this.someField= in.readString();
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeParcelable(markerOptions, flags);
dest.writeString(someField);
}
public static final Parcelable.Creator<Foo> CREATOR = new Parcelable.Creator<Foo>() {
public Foo createFromParcel(Parcel in) {
return new Foo(in);
}
public Foo[] newArray(int size) {
return new Foo[size];
}
};
}
如何读写 MarkerOptions?