public class Category implements Parcelable {
private int mCategoryId;
private List<Video> mCategoryVideos;
public int getCategoryId() {
return mCategoryId;
}
public void setCategoryId(int mCategoryId) {
this.mCategoryId = mCategoryId;
}
public List<Video> getCategoryVideos() {
return mCategoryVideos;
}
public void setCategoryVideos(List<Video> videoList) {
mCategoryVideos = videoList;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeInt(mCategoryId);
parcel.writeTypedList(mCategoryVideos);
}
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
public Category createFromParcel(Parcel parcel) {
final Category category = new Category();
category.setCategoryId(parcel.readInt());
category.setCategoryVideos(parcel.readTypedList()); */// **WHAT SHOULD I WRITE HERE***
return category;
}
public Category[] newArray(int size) {
return new Category[size];
}
};
}
Im mój kod używam modelu, który implementuje z parcelable ... Czy ktoś może powiedzieć im, co krzyk piszę w tej linii category.setCategoryVideos(parcel.readTypedList())
nie mogłem znaleźć żadnego pomocny post.Jak napisać List <> na działce
EDYTOWANIE: category.setCategoryVideos(parcel.readTypedList(mCategoryVideos,Video.CREATOR));
tutaj mCategoryVideos Nie mogę rozwiązać błędu.
Ta odpowiedź powinna być oznaczone jako poprawne, jedno tho jest to, że lista musi zawierać Parcelable obiektów, jak również. –
Bardzo niewielka korekta: 'parcel.readList (myList, ElementType.class.getClassLoader());' – WindRider
NullPointerException –