Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><em>All of the below assumes you have already parsed the JSON out into an array. See <a href="http://www.androidcompetencycenter.com/2009/10/json-parsing-in-android/" rel="nofollow" title="this">this for parsing help.</a></em></p> <p>ListViews use adapters to grab the elements to fill the list rows up with. You'll have to feed the JSON results into a SimpleListAdapter via a List or array (ArrayList, what have you.).</p> <p>from <a href="http://mylifewithandroid.blogspot.com/2008/03/my-first-meeting-with-simpleadapter.html" rel="nofollow">this page about listviews</a>:</p> <pre><code>SimpleAdapter nommes = new SimpleAdapter( this, list, R.layout.main_item_two_line_row, new String[] { "line1","line2" }, new int[] { R.id.text1, R.id.text2 } ); </code></pre> <p>(in your case you could show/hide the id/name by using a one-line layout or a two-line layout like in this example)</p> <p>Then apply the adapter</p> <pre><code>listView.setAdapter(nommes); </code></pre> <p><strong>EDIT:</strong></p> <pre><code>jObject = new JSONObject("&lt;your JSON string from provider&gt;"); // in my case: res = jObject.getJSONObject("results"); **dataAdapter = new ArrayAdapter&lt;String&gt;(this, R.layout.item, R.id.itemName);** try { for (int r = 0; r &lt; rslt.length(); r++){ JSONArray jA = rslt.getJSONArray(Integer.toString(r)); schoolLocString = jA.getString(0) +"|"+ jA.getString(1) +"[" + jA.optString(2); **dataAdapter.add(schoolLocString);** } **myListView.setListAdapter(dataAdapter);** } catch (JSONException e) { Log.v(TAG, "Exception " + e); } catch (NullPointerException e){ Log.v(TAG, "NPE, no rslt"); } </code></pre> <p>This is a really lazy way to do it and probably bad practice, but you can get the idea.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload