伙计们,我正在尝试在下面解析这个 JSON
{"response":
{"message": "Success",
"code": 2002,
"payload":
{"article": [
{"timestamp_epoch": 1359967680,
"search_score": 10.0,
"headline": "When Sachin felt like bunking cricket practice",
"timestamp": "2013-02-04 08:48:00",
"related_article_count": 0,
"excerpt": "...their campaign 'Support my School' by NDTV in Mumbai on Sunday. Sachin Tendulkar and Aishwarya Rai Bacchan during an event 3/5 Sachin Tendulkar and Aishwarya Rai Bacchan during an event India's Sachin Tendulkar with actress Aishwarya Rai Bachchan during the...",
"source": {"name": "OneIndia",
"url": "http://www.oneindia.in/",
"daylife_url": "http://www.daylife.com/source/OneIndia",
"rank": 3,
"favicon_url": "http://favicon.daylife.com/imageserve/0e0Jd1Xczb7oW/favicon.png",
"source_id": "0e0Jd1Xczb7oW",
"type": "MAINSTREAM"},
"url": "http://feedproxy.google.com/~r/oneindia-cricket/~3/z1pS6w289SU/when-sachintendulkar-felt-like-bunking-cricket-practice-066016.html",
"daylife_url": "http://www.daylife.com/article/07nC5eTbBE0YA",
"article_id": "07nC5eTbBE0YA"},
{"timestamp_epoch": 1360361400,
"search_score": 8.69279902947,
"headline": "Sachin equals Sunny",
.
.
.
.
.
我只对标题和网址值感兴趣。我很容易用下面的这个java代码得到这些值。
JSONObject root = new JSONObject(result);
JSONObject response = root.getJSONObject("response");
String attributeId = response.getString("message");
System.out.println(attributeId);
JSONObject payload = response.getJSONObject("payload");
JSONArray article = payload.getJSONArray("article");
for (int i = 0; i < article.length(); i++) {
JSONObject c = article.getJSONObject(i);
String headline = c.getString("headline");
String url = c.getString("url");
System.out.println(url);
System.out.println(headline);
strings.add(c.getString("headline").toString());
}
arrayAdapter = new ArrayAdapter<String>(MainActivity.this,
android.R.layout.simple_list_item_1, strings);
resultList.setAdapter(arrayAdapter);
arrayAdapter.notifyDataSetChanged();
在这里,我在ListView中设置标题(这部分工作正常)。我的问题是:当我单击任何列表时,它应该将相应的url传递给WebView活动(实际上我正在另一个类中实现它)。那么如何实现这一点,如何存储对应的url和标题?请有人帮助我..
提前致谢..