嗨,我有一个像这样实现 Parcelable 的类:
public class adapterSource implements Parcelable {
String adiSoyadi;
String isemriTipi;
String ililce;
String mahalle;
String saat;
String durum;
private List<adapterSource> s;
public adapterSource(String adiSoyadi, String isemriTipi,String ililce, String mahalle, String saat, String durum ) {
this.adiSoyadi = adiSoyadi;
this.isemriTipi = isemriTipi;
this.ililce = ililce;
this.mahalle = mahalle;
this.saat = saat;
this.durum = durum;
}
public adapterSource(Parcel in) {
s = new ArrayList<adapterSource>();
in.readList(s, in.getClass().getClassLoader());
adiSoyadi=in.readString();
isemriTipi=in.readString();
ililce=in.readString();
mahalle=in.readString();
saat=in.readString();
durum=in.readString();
}
public int describeContents() {
return 0;
}
public void writeToParcel(Parcel arg0, int arg1) {
}
public static final Parcelable.Creator<adapterSource> CREATOR = new Parcelable.Creator<adapterSource>() {
public adapterSource createFromParcel(Parcel in) {
return new adapterSource(in);
}
public adapterSource[] newArray(int size)
{
return new adapterSource[size];
}
};
}
我正在尝试在这样的一项活动中创建此类的一个实例:
adapterSource[] source = new adapterSource[7];
source[0] = (adapterSource) new adapterSource("isa", "isa", "asd", "asd", "asd", "asd");
source[1] = new adapterSource("isa", "isa", "asd", "asd", "asd", "asd");
source[2] = new adapterSource("isa", "isa", "asd", "asd", "asd", "asd");
source[3] = new adapterSource("isa", "isa", "asd", "asd", "asd", "asd");
source[4] = new adapterSource("isa", "isa", "asd", "asd", "asd", "asd");
source[5] = new adapterSource("isa", "isa", "asd", "asd", "asd", "asd");
source[6] = new adapterSource("isa", "isa", "asd", "asd", "asd", "asd");
Intent in = new Intent().setClass(this, MainListActivity.class);
in.putExtra("source", source);
startActivity(in);
我正在从另一个这样的活动中打电话:
adapterSource[] ada= (adapterSource[]) this.getIntent().getParcelableArrayExtra("source");
我得到了解组错误。问题是什么。请帮忙...