title: Android JSON dosn't display data into list view
body: <p>I'm newbie in android programming, and going crazy with my problem.. I have readed about ~30 tutorials <strong>How to display JSON data into Android</strong>, but can't fix code, so it work. (At this moment, I don't get any errors. And my JSON file is working.</p>
  
  <p>So you don't ask, why I'm using ImageButtons - It's because (when I get this working), I want to display clickable images for each post(Like upvote button, downvote button and more).</p>
  
  <p>I have looked in many tutorials and stackoverflow questions, but in each page code are really different and this was most simpliest of all.</p>
  
  <p>FunActivity(MainActivity).java</p>
  
  <pre><code>package crelix.carparadise;
  
  import android.os.AsyncTask;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.widget.ArrayAdapter;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  import android.widget.SimpleAdapter;
  import android.widget.Toast;
  
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  import java.io.BufferedReader;
  import java.io.InputStreamReader;
  import java.net.HttpURLConnection;
  import java.net.URL;
  import java.util.ArrayList;
  import java.util.HashMap;
  
  public class FunActivity extends AppCompatActivity {
  ListView listView;
  ArrayList&lt;HashMap&lt;String, String&gt;&gt; postList;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_fun);
  
      listView = (ListView) findViewById(R.id.listView);
      getJSON("http://10.10.7.6/Android/Pages/Fun.php");
  }
  
  
  private void getJSON(final String urlWebService) {
  
      class GetJSON extends AsyncTask&lt;Void, Void, String&gt; {
  
          @Override
          protected void onPreExecute() {
              super.onPreExecute();
          }
  
  
          @Override
          protected void onPostExecute(String s) {
              super.onPostExecute(s);
  
              try {
                  loadIntoListView(s);
              } catch (JSONException e) {
                  e.printStackTrace();
              }
          }
  
          @Override
          protected String doInBackground(Void... voids) {
              try {
                  URL url = new URL(urlWebService);
                  HttpURLConnection con = (HttpURLConnection) url.openConnection();
                  StringBuilder sb = new StringBuilder();
                  BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(con.getInputStream()));
                  String json;
                  while ((json = bufferedReader.readLine()) != null) {
                      sb.append(json + "\n");
                  }
                  return sb.toString().trim();
              } catch (Exception e) {
                  return null;
              }
          }
      }
      GetJSON getJSON = new GetJSON();
      getJSON.execute();
  }
  
  private void loadIntoListView(String json) throws JSONException {
      JSONArray jsonArray = new JSONArray(json);
  
      for (int i = 0; i &lt; jsonArray.length(); i++) {
  
          JSONObject posts = jsonArray.getJSONObject(i);
          String id = posts.getString("id");
          String title = posts.getString("title");
          String image = posts.getString("image");
          String upvotes = posts.getString("upvotes");
          String downvotes = posts.getString("downvotes");
          String comments = posts.getString("comments");
          String share = posts.getString("share");
          String report = posts.getString("report");
          String date = posts.getString("date");
          String addedby = posts.getString("addedby");
  
  
          // tmp hash map for single contact
          HashMap&lt;String, String&gt; post = new HashMap&lt;&gt;();
  
          // adding each child node to HashMap key =&gt; value
          post.put("id", id);
          post.put("title", title);
          post.put("image", image);
          post.put("upvotes", upvotes);
          post.put("downvotes", downvotes);
          post.put("comments", comments);
          post.put("share", share);
          post.put("report", report);
          post.put("date", date);
          post.put("addedby", addedby);
  
          // adding contact to contact list
          postList.add(post);
      }
  
      ListAdapter adapter = new SimpleAdapter(FunActivity.this, postList,
              R.layout.fun_posts, new String[]{ "title","image","upvotes","downvotes","comments","share","report","date","addedby"},
              new int[]{R.id.titleTv, R.id.imageBtn, R.id.upvoteBtn, R.id.downvoteBtn, R.id.commentBtn, R.id.shareBtn, R.id.reportBtn, R.id.date, R.id.addedbyBtn});
      listView.setAdapter(adapter);
  
  }
  }
  </code></pre>
  
  <p>fun_posts(list_item).xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  android:orientation="vertical"&gt;
  
  &lt;TextView
      android:id="@+id/titleTv"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" /&gt;
  
  &lt;ImageButton
      android:id="@+id/imageBtn"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" /&gt;
  
  &lt;ImageButton
      android:id="@+id/upvoteBtn"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" /&gt;
  
  &lt;ImageButton
      android:id="@+id/downvoteBtn"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" /&gt;
  
  &lt;ImageButton
      android:id="@+id/commentBtn"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" /&gt;
  
  &lt;ImageButton
      android:id="@+id/shareBtn"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" /&gt;
  
  &lt;ImageButton
      android:id="@+id/reportBtn"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" /&gt;
  
  &lt;TextView
      android:id="@+id/date"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" /&gt;
  
  &lt;TextView
      android:id="@+id/addedbyBtn"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>And activity_fun.xml(Main layout)</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.ConstraintLayout 
  xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="crelix.carparadise.FunActivity"&gt;
  
  &lt;ListView
      android:id="@+id/listView"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true"
      android:layout_alignParentTop="true"&gt;
  &lt;/ListView&gt;
  </code></pre>
  
  <p></p>