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 il mio codice che sto usando il modello che implementa da Parcelable ... Qualcuno potrebbe dire che cosa em grido che scrivo in questa linea category.setCategoryVideos(parcel.readTypedList())
non ho potuto trovare alcun posto disponibile.Come scrivere List <> in pacco
MODIFICA: category.setCategoryVideos(parcel.readTypedList(mCategoryVideos,Video.CREATOR));
qui mCategoryVideos Non riesco a risolvere l'errore.
Questa risposta deve essere contrassegnato come corretta, una cosa tho è che la lista deve contenere oggetti Parcelable pure. –
Correzione molto piccola: 'parcel.readList (myList, ElementType.class.getClassLoader());' – WindRider
NullPointerException –