Note that there are some explanatory texts on larger screens.

plurals
  1. POlisting dynamic content from a json array to listview
    primarykey
    data
    text
    <p>my situation is the following: I get a JSON-Array as response from a php script on a server after I sent a hash to it. There are two possible formations of the JSON-Array. If the hash is not valid, the first would be just like <code>{"status":0}</code>. Second formation, when the hash is valid, it would have appointments in it -> would be like <code>{"appointmentName":"Meeting","date":"2013-03-15","startTime":"10:00:00","endTime":"12:10:00","status":2}</code>. </p> <p>The JSON-Array could be filled with more than just one appointment. See below:</p> <pre><code>{ "appointmentName": "Proposal", "date": "2013-11-11", "startTime": "09:00:00", "endTime": "13:00:00", "status": 2 } { "appointmentName": "Meeting", "date": "2013-03-15", "startTime": "10:00:00", "endTime": "12:10:00", "status": 2 } </code></pre> <p>I want to list those appointments in a ListView on the android-app. </p> <p>My method that handles the the JSON-Array:</p> <pre><code>public void handleActivationResult(String result) { try { JSONObject jsonObject = new JSONObject(new String(result)); String statusCode = jsonObject.getString("status"); TextView mainView = (TextView) findViewById(R.id.textView1); if (statusCode.equals("2")) { //fill listview with appointments } else if (statusCode.equals(0)) { //empty string sent to server } else if (statusCode.equals(5)) { //hash doesnt match } else if (statusCode.equals(6)) { //correct hash, but no upcoming appointments } else { //unknown error } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } </code></pre> <p>My ListView isnt something special yet:</p> <pre><code>&lt;ListView android:id="@+id/appointmentsList" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" &gt; &lt;/ListView&gt; </code></pre> <p>How should it bee, that the handleActivationResult() method will fill the list with the appointments?</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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