嗨那裏我沒有得到任何錯誤,但由於某種原因,它不填寫我的名單json飼料有一個新聞陣列裏面是一個標題稱爲標題,我想顯示標題在一個列表視圖。但目前它只顯示一個空白屏幕。繼承人我的代碼Android Json字符串不填充列表
try {
// Instantiate a JSON object from the request response
JSONObject obj = new JSONObject(json);
List<String> items = new ArrayList<String>();
JSONArray jArray = obj.getJSONArray("news");
for (int i = 0; i < jArray.length(); i++) {
JSONObject oneObject = jArray.getJSONObject(i);
items.add(oneObject.getString("title"));
}
setListAdapter(new ArrayAdapter<String>(this, R.layout.single_item,
items));
ListView list = getListView();
list.setTextFilterEnabled(true);
list.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(),
((TextView) arg1).getText(), 1000).show();
}
});
} catch (Exception e) {
// In your production code handle any errors and catch the
// individual exceptions
e.printStackTrace();
}
請發佈您試圖解析的JSON樣本。我們不是魔術師;) – 2012-03-09 17:35:54
抱歉繼承人json {「code」:200,「error」:null,「data」:{「news_id」:「8086」,「title」:「Tickets年度最佳球員獎「, – iamlukeyb 2012-03-10 23:17:02