我正在尝试在我的微调器上添加json对象但是按照我的方式给出了正确的结果我跟随https://inducesmile.com/android/populate-android-spinner-data-from-remote-mysql-database/please的tutoreal建议我。
input: "ABC"|"CDS"|""gurgaon""|"ABC"|"CDS"|""gaon""
Output: "ABC"|"CDS"|"/"gurgaon"|"ABC"|"CDS"|"/"gaon
}
@SerializedName("Status")
@Expose
private String status;
@SerializedName("ExpiryDate")
@Expose
private String expiryDate;
@SerializedName("MessagesLeft")
@Expose
private String messagesLeft;
@SerializedName("Users")
@Expose
private List<User> users = null;
@SerializedName("Balance")
@Expose
private String balance;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getExpiryDate() {
return expiryDate;
}
public void setExpiryDate(String expiryDate) {
this.expiryDate = expiryDate;
}
public String getMessagesLeft() {
return messagesLeft;
}
public void setMessagesLeft(String messagesLeft) {
this.messagesLeft = messagesLeft;
}
public List<User> getUsers() {
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
public String getBalance() {
return balance;
}
public void setBalance(String balance) {
this.balance = balance;
}
导入com.google.gson.annotations.SerializedName;
公共类用户{
import com.google.gson.annotations.Expose;
} 和Adpater Class就是这样。
@SerializedName("username")
@Expose
private String username;
@SerializedName("userid")
@Expose
private String userid;
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getUserid() {
return userid;
}
public void setUserid(String userid) {
this.userid = userid;
}
}
答案 0 :(得分:0)
您正尝试将列表设置为textview,这是不可能的,请尝试按照代码设置文本
spinnerHolder.spinnerItemList.setText(listData.get(position).getUsers().get(0).getUsername());
答案 1 :(得分:0)
您正在尝试将列表数据设置为TextView视图。而不是尝试此状态,其中position将是您要显示的用户位置
spinnerHolder.spinnerItemList.setText(listData.get(position).getUsers().get(position).getUsername());