我的回答如下所示
"data":[
{
"title": "hbdv",
"description" : [
"a", "b", "c"
]
},
{
"title": "bdvv",
"description": [
"d", "f"
]
}
]
我创建了一个自定义模型,例如X
然后
@SerializedName("title") String a;
@SerializedName("description") ???
如何创建实现parcelable
的模型。
答案 0 :(得分:0)
创建模型并使用Parcelable实施它
那么您需要生成一些方法
1-具有宗地输入参数的构造函数
2-创作者
3-覆盖describeContents方法
4-最终重写writeToParcel方法
例如
import android.os.Parcel;
import android.os.Parcelable;
public class yourClass implements Parcelable{
private String title;
private String[] description;
private yourClass(Parcel in) {
title = in.readString();
description = in.createStringArray();
}
public static final Creator<yourClass> CREATOR = new Creator<yourClass>() {
@Override
public yourClass createFromParcel(Parcel in) {
return new yourClass(in);
}
@Override
public yourClass[] newArray(int size) {
return new yourClass[size];
}
};
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeString(title);
parcel.writeStringArray(description);
}
}