【发布时间】:2013-09-20 10:54:29
【问题描述】:
我首先将 JSON 数组“日期”存储在 arratstring 中,如果匹配,则将我的日期与列表匹配,然后在此行之后显示该日期的“标题”名称if (Vacation_Date.contains(mydate)) {
我只想在 textview 中打印与该日期标题名称匹配的值,请问我该怎么做?
static ArrayList<Long> Vacation_ID = new ArrayList<Long>();
static ArrayList<String> Vacation_name = new ArrayList<String>();
static ArrayList<String> Vacation_Date = new ArrayList<String>();
JSONObject json3 = new JSONObject(str2);
status = json3.getString("status");
if (status.equals("1")) {
JSONArray school = json3.getJSONArray("data");
for (int k = 0; k < school.length(); k++) {
JSONObject jb = (JSONObject) school.getJSONObject(k);
Vacation_ID.add((long) k);
Vacation_Date.add(jb.getString("date"));
}
}
来自Vacation_Date 中 json 文件的强数组“日期”。现在我将我的日期与 Vacation_Date 进行比较,并检查我的日期是否存在于 Vacation_Date 中,并在 textview 中显示其标题名称。
if (Vacation_Date.contains(mydate))
//现在我要做什么来显示比赛日期的标题名称
textview.settext ("title name of match date")'
}
JSON
{"status":1,
"data":
[
{"id":"1",
"title":"abc",
"date":"2013-09-29"},
{"id":"2",
"title":"abc1",
"date":"2013-09-25"},
{"id":"3",
"title":"abc",
"date":"2013-10-05"},
{"id":"4",
"title":"abc1",
"date":"2013-09-27"}
]
}
【问题讨论】:
-
你能格式化你的代码吗?
-
-
在 textview 中显示有什么问题。解析有问题?
-
我只想在 textview 中显示与 mydate 匹配的标题
-
@smartguy:Houcine 已经回复并且应该可以了。我花了几分钟才真正理解了这个问题。只是一个建议,继续努力把问题解释清楚一点。