Hi I am new to spinner use, never used it before and also populating it with the json data. I am trying to find some solution or atleast learn few things on how to do that, but not able to get any understandable solution. Would appreciate if someone can guide me on a proper path.
My JSON data looks something like below,
{
"Devices": [
{
"type": "alarm",
"displayType": "Alarm",
"imageId": "alarm"
},
{
"type": "audio_bridge",
"displayType": "Audio Bridge",
"imageId": "audio"
},
{
"type": "av_receiver",
"displayType": "Av Receiver",
"imageId": "default"
},
{
"type": "baby_monitor",
"displayType": "Baby Monitor",
"imageId": "mobile"
},
{
"type": "baseport",
"displayType": "Baseport",
"imageId": "default"
},
{
"type": "camera",
"displayType": "Camera",
"imageId": "camera"
},
{
"type": "console",
"displayType": "Console",
"imageId": "console"
}
]
}
I need to just pull displayType from this JSON. And I have a model class to follow through and fetch whatever data needed as below,
@SerializedName("type")
@Expose
private String type;
@SerializedName("displayType")
@Expose
private String displayType;
@SerializedName("imageId")
@Expose
private String imageId;
protected Devices(Parcel in) {
type = in.readString();
displayType = in.readString();
imageId = in.readString();
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeValue(type);
parcel.writeValue(displayType);
parcel.writeValue(imageId);
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getDisplayType() {
return displayType;
}
public void setDisplayType(String displayType) {
this.displayType = displayType;
}
public String getImageId() {
return imageId;
}
public void setImageId(String imageId) {
this.imageId = imageId;
}
the thing is I wanted to list all the displayType dynamically based on json into spinner in my activity.