包裹:无法编组值Vector3

时间:2016-02-19 14:51:05

标签: java android android-intent parcelable

我正在尝试将包含一个arraylist的Model对象从一个活动传递给另一个,但似乎我错过了一些Parcelable类或意图的东西。

这是我得到的错误:

java.lang.RuntimeException: Parcel: unable to marshal value Vector3 <x, y, z>: <-0.5, -0.5, 0.0>

模型类

public class Model implements Parcelable{
public List<Stack> surfaces;
public Info info;

public Model(List<Stack> surf){
    surfaces = surf;
}

public void setInfo(Info i){
    info=i;
}

public Info getInfo(){
    return info;
}

public List<Stack> getSurfaces(){
    return surfaces;
}

public int numSurfaces(){
    return surfaces.size();
}

public int describeContents() {
    return 0;
}

public void writeToParcel(Parcel out, int flags) {
    out.writeList(surfaces);
    Parcelable infoP = ((Parcelable) info);
    out.writeParcelable(infoP, 0);
}

public static final Parcelable.Creator<Model> CREATOR
        = new Parcelable.Creator<Model>() {
    public Model createFromParcel(Parcel in) {
        return new Model(in);
    }

    public Model[] newArray(int size) {
        return new Model[size];
    }
};

private Model(Parcel in) {
    surfaces = new ArrayList<Stack>();
    in.readList(surfaces, Stack.class.getClassLoader());
    info = in.readParcelable(Info.class.getClassLoader());
}

public class Info{
    String title;
    String descr;

    public Info(String t, String d){
        title=t;
        descr=d;
    }

    public Info(String t){
        title=t;
    }

    public void setDescr(String d){
        descr=d;
    }
}}

第一项活动

...
Model model= new Model(surfaces);

Intent intent = new Intent(this, EditorPresenter.class);
intent.putExtra("model", model);
startActivity(intent);

第二项活动

...
Intent intent = getIntent();
model= intent.getParcelableExtra("points");
surf = model.surfaces.toArray(new Stack[model.numSurfaces()]);
...

任何帮助都非常感激。

0 个答案:

没有答案