嗨刚刚得到一个错误,我不知道为什么任何人都可以帮忙?Android的setlistAdapter错误
这是我的JSON提要是如何构成的,我想这个消息阵列
{ “代码”:200, “错误”:空, “数据”:{ “新闻”:[{ “news_id”:” 8086“ 我在这里得到一个错误:在oneOjectsItem
setListAdapter(new ArrayAdapter(this,R.layout.single_item,oneObjectsItem));
这里我的代码
// Instantiate a JSON object from the request response
JSONObject jsonObject = new JSONObject(json);
JSONArray jArray = jsonObject.getJSONArray("news");
for (int i=0; i < jArray.length(); i++)
{
JSONObject oneObject = jArray.getJSONObject(i);
// Pulling items from the array
String oneObjectsItem = oneObject.getString("title");
}
} catch(Exception e){
// In your production code handle any errors and catch the individual exceptions
e.printStackTrace();
}
setListAdapter (new ArrayAdapter<String>(this, R.layout.single_item, oneObjectsItem));
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();
}
});
}
你得到的错误是什么? – jmishra 2012-03-07 23:07:31
如果出现错误,请给出日志。或者,它是第一次加载? – dcanh121 2012-03-08 00:06:22