【发布时间】:2017-02-04 06:23:08
【问题描述】:
我有一个listView 并且我为每个主题显示students attendance,我正在解析JSON 直到secondlast 的位置。为此,在获取计数时,我确实返回了attendanceBeanList.size()-1。请参见下面的代码。
我已经这样做了:
private List<TotalAttendance_Bean> attendanceBeanList;
public TotalAttendanceAdapter(Activity activity, List<TotalAttendance_Bean> attendanceBeanList)
{
super();
this.activity = activity;
this.attendanceBeanList = attendanceBeanList;
}
@Override
public int getCount() {
return attendanceBeanList.size()-1;
}
现在,当我要获取最后一个对象时,我被卡住了。我必须得到每个学生的总出勤率。为此,我必须从 JSONArray 下方获取 Last Object。
这是我的 JSON:
[
{
"subject_name": "English-I",
"total_classes": "2",
"total_attended": "2",
"percentage": "100"
},
{
"subject_name": "English-I",
"total_classes": "2",
"total_attended": "2",
"percentage": "100"
},
{
"subject_name": "English-I",
"total_classes": "2",
"total_attended": "2",
"percentage": "100"
},
{
"subject_name": "English-I",
"total_classes": "2",
"total_attended": "2",
"percentage": "100"
},
{
"total_attendance": 90%
}
]
这是我的 XML。 在此布局中,我在列表视图中显示每个主题出勤率,并且我必须在 TextView 中以蓝色显示总百分比。
【问题讨论】:
-
您发布的 Json 无效,请使用验证器并更正代码
-
先生,我也检查过,它显示“有效 JSON”。我们不能在这个 JSON 中做吗