2
我正在使用Retrofit從後端加載數據。 POJO實現Parcelable。我在閱讀和寫入POJO時遇到問題。我認爲這是因爲字段名稱與我從後端獲得的名稱不同。這裏的POJO:Parcelable沒有爲POJO字段設置正確的值
@SerializedName("poster_path")
public String posterPath;
....
private Movie(Parcel in) {
...
posterPath= in.readString();
...
}
...//more code
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(posterPath);
}
當我通過intent.getParcelableExtra得到POJO中,posterPath爲空。我究竟做錯了什麼。
您必須按照您寫入的順序讀取「包裹」中的數據。你在做這個嗎? – Mauker
是的,這是問題!我固定了訂單,現在它正在工作!謝謝 – Sai
我會將它作爲答案張貼:)不要忘記將其標記爲已接受。 – Mauker