我有一个正在尝试转换为Parcelable的类。它具有一个指向其自身类的另一个对象的节点。
class Node<T> implements Parcelable {
public Node<String> parent = null;
public T year;
public String name = null;
public Node(T year, Node<String> parent,String name) {
//children = new ArrayList<Node<T>>();
this.year = year;
this.parent = parent;
this.name = name;
}
protected Node(Parcel in) {
parent = in.readParcelable(Node<String>.class.getClassLoader());
name = in.readString();
}
public static final Creator<Node> CREATOR = new Creator<Node>() {
@Override
public Node createFromParcel(Parcel in) {
return new Node(in);
}
@Override
public Node[] newArray(int size) {
return new Node[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeParcelable(parent, i);
parcel.writeString(name);
}
}
我在节点上收到无法从参数化类型中选择:
parent = in.readParcelable(Node<String>.class.getClassLoader());
如何解决此错误? 谢谢您的提前帮助