多个检查项目发送参数

时间:2019-06-18 09:13:36

标签: android json

启用开关盒后,我已在适配器中设置了开关盒,然后打开自定义复选框列表项。我已选中多个复选框。选择微调器项目然后打开片段页面时,此开关盒设计。选择多个复选框项并发送JSON参数,如下所示:

"attendees": [
      {
        "id": "1",
        "person": "xza"
      },
      {
        "id": "2",
        "person": "cfd"
      }
    ]

并在活动中应用发送按钮。在活动中微调并保存按钮设计,然后在片段中选择项目设计。

我有像这样的模型课:

public class MeetingModel {

public String date;
public String time;
public boolean reminder;
public boolean assignTOther;
public boolean contactTo;
public boolean attendeesTo;
public String remark;
private MeetingReminder meetingReminder;
private int assignid;
private int contactid;
private List<Assigne> attendees = null;
private int attendeesid;
private String location;
private String purpose;
private String clientType;
private String id;
private String logSubType;

public String getDate() {
    return date;
}

public void setDate(String date) {
    this.date = date;
}

public String getTime() {
    return time;
}

public void setTime(String time) {
    this.time = time;
}

public boolean isReminder() {
    return reminder;
}

public void setReminder(boolean reminder) {
    this.reminder = reminder;
}

public boolean isAssignTOther() {
    return assignTOther;
}

public void setAssignTOther(boolean assignTOther) {
    this.assignTOther = assignTOther;
}

public boolean isContactTo() {
    return contactTo;
}

public void setContactTo(boolean contactTo) {
    this.contactTo = contactTo;
}

public boolean isAttendeesTo() {
    return attendeesTo;
}

public void setAttendeesTo(boolean attendeesTo) {
    this.attendeesTo = attendeesTo;
}

public String getRemark() {
    return remark;
}

public void setRemark(String remark) {
    this.remark = remark;
}

public MeetingReminder getMeetingReminder() {
    return meetingReminder;
}

public void setMeetingReminder(MeetingReminder meetingReminder) {
    this.meetingReminder = meetingReminder;
}

public int getAssignid() {
    return assignid;
}

public void setAssignid(int assignid) {
    this.assignid = assignid;
}

public int getContactid() {
    return contactid;
}

public void setContactid(int contactid) {
    this.contactid = contactid;
}

public void setMeetingReminder(String date, String time) {
    MeetingReminder meetingReminder = new MeetingReminder();
    meetingReminder.setDate(date);
    meetingReminder.setTime(time);
    setMeetingReminder(meetingReminder);

}

public String getLocation() {
    return location;
}

public void setLocation(String location) {
    this.location = location;
}

public String getPurpose() {
    return purpose;
}

public void setPurpose(String purpose) {
    this.purpose = purpose;
}

public String getClientType() {
    return clientType;
}

public void setClientType(String clientType) {
    this.clientType = clientType;
}

public String getId() {
    return id;
}

public void setId(String id) {
    this.id = id;
}

public String getLogSubType() {
    return logSubType;
}

public void setLogSubType(String logSubType) {
    this.logSubType = logSubType;
}


public List<Assigne> getAttendees() {
    return attendees;
}

public void setAttendees(List<Assigne> attendees) {
    this.attendees = attendees;
}

public JsonArray getCheckedItems(){
    List<Assigne>  tmpList=new ArrayList<>();
    List<Assigne> attendees = new ArrayList<>();
    JsonArray jsonArray = new JsonArray();
    for(Assigne attendee:attendees){
        if(attendee.isHeaderSelected()){
            tmpList.add(attendee);
            attendee.setHeaderSelected(true);
            JsonObject obj = new JsonObject();
            obj.addProperty("id", attendee.getId());
            obj.addProperty("name", attendee.getName());
            jsonArray.add(obj);
        }
    }
    return jsonArray;
}
}

我希望输出是:

  

“与会者”:[{“ id”:“ 1”,“ person”:“ fff”},{“ id”:“ 2”,“ person”:“ dfdf”}]

但是实际输出是:

  

“与会者”:[]

0 个答案:

没有答案