我需要解析一个JSON
并在JSON
的帮助下我需要制作动态列表视图(它可以是2或3或任何)。
[
{
"Monday, Feb 16": [
{
"Time": "19-02-2015 12:00:00",
"Image": "India.png",
"Currency": " INR",
"Event": "WPI Food (YoY) (Jan)",
"Actual": "8.00%",
"Forcast": "",
"Previous": "5.20%"
},
{
"Time": "19-02-2015 12:00:00",
"Image": "India.png",
"Currency": " INR",
"Event": "WPI Fuel (YoY) (Jan)",
"Actual": "-10.69%",
"Forcast": "",
"Previous": "-7.80%"
},
{
"Time": "19-02-2015 12:00:00",
"Image": "India.png",
"Currency": " INR",
"Event": "WPI Inflation (YoY) (Jan)",
"Actual": "-0.39%",
"Forcast": "0.41%",
"Previous": "0.11%"
},
{
"Time": "19-02-2015 12:00:00",
"Image": "India.png",
"Currency": " INR",
"Event": "WPI Manufacturing Inflation (YoY) (Jan)",
"Actual": "1.05%",
"Forcast": "",
"Previous": "1.57%"
}
]
},
{
"Wednesday, Feb 18": [
{
"Time": "19-02-2015 17:00:00",
"Image": "India.png",
"Currency": " INR",
"Event": "M3 Money Supply (2wk)",
"Actual": "11.40%",
"Forcast": "",
"Previous": "11.20%"
}
]
},
{
"Friday, Feb 20": [
{
"Time": "19-02-2015 17:00:00",
"Image": "India.png",
"Currency": " INR",
"Event": "Bank Loan Growth (2wk)",
"Actual": "",
"Forcast": "",
"Previous": "10.70%"
},
{
"Time": "19-02-2015 17:00:00",
"Image": "India.png",
"Currency": " INR",
"Event": "Deposit Growth (2wk)",
"Actual": "",
"Forcast": "",
"Previous": "11.60%"
},
{
"Time": "19-02-2015 17:00:00",
"Image": "India.png",
"Currency": " INR",
"Event": "FX Reserves, USD",
"Actual": "",
"Forcast": "",
"Previous": "330.21B"
}
]
}
]
此处“2月16日星期一”“2月18日星期三”“2月20日星期五”应为3个标题,并显示我们需要制作3个列表视图,其他则是列表视图的项目。
我解析了json获取所有键和项目。现在我如何动态制作列表视图。
JSONArray jsonArray = new JSONArray(sResponse);
for (int i = 0; i < jsonArray.length(); i++) {
JSONObject jObj = jsonArray.getJSONObject(i);
Iterator<?> keys = jObj.keys();
// while (keys.hasNext()) {
String key = (String) keys.next();
JSONArray jArr = jObj.getJSONArray(key);
Log.e("Key", "Key :-" + key);
for (int i1 = 0; i1 < jArr.length(); i1++) {
JSONObject jsO = jArr.getJSONObject(i1);
Log.e("Event", jsO.getString("Event"));
}
我们将不胜感激。