Android App: JSON array from web to listview
This works in a simple test app I just created...
ListView list = (ListView) findViewById(...);String json = "[\"Country1\",\"Country2\",\"Country3\"]";try { JSONArray array = (JSONArray) new JSONTokener(json).nextValue(); String[] stringarray = new String[array.length()]; for (int i = 0; i < array.length(); i++) { stringarray[i] = array.getString(i); } ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, stringarray); list.setAdapter(adapter);} catch (JSONException e) { // handle JSON parsing exceptions...}