I have a code which does following –
- Connect to a web service via HttpClient to PHP file
- Returns a result from an SQL query
- Returns format is a jArray (a JSONArray)
for(int i=0; i < jArray.length() ; i++) {
json_data = jArray.getJSONObject(i);
int id=json_data.getInt("id");
String name=json_data.getString("name");
Log.d(name,"Output");
}
When I look at the LogCat, I see all the “names” of the query, Each record is printed. I just need to plug these results into a ListView. How can I accomplish this ?
PS – I do not have a separate class for an ArrayAdapter. Could this be the reason ?
If you just want to display a list of textViews you don’t need to override anything, you can just add all of the items into an arrayList and use an arrayAdapter.
Put a list view in your xml that is named android:list and then create your arrayAdapter with the textView you want to use.
After that all you have to do is call setListAdapter(mArrayAdapter) and it should populate your list.
hope this helps!