hi there I'm not getting any errors but for some reason its not filling my list the json feed has an array of news inside that is a tag called title and i want to display the titles in a list view. but at the moment it just displays a blank screen. heres my code
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();
}