title: Displaying data from URL into listview
body: <p>I have created an app which fetches data from a URL using a JSON array request when I display the data from URL like this:</p>
  
  <p><a href="https://i.stack.imgur.com/DBF4y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DBF4y.png" alt="it is like this"></a></p>
  
  <p>how can I show this data in a listview? Here is my code:</p>
  
  <pre><code>public class JsonRequestActivity extends Activity implements OnClickListener {
  
  private String TAG = JsonRequestActivity.class.getSimpleName();
  private Button btnJsonObj, btnJsonArray;
  private TextView msgResponse;
  private ProgressDialog pDialog;
  
  // These tags will be used to cancel the requests
  private String tag_json_obj = "jobj_req", tag_json_arry = "jarray_req";
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_json);
  
      btnJsonObj = (Button) findViewById(R.id.btnJsonObj);
      btnJsonArray = (Button) findViewById(R.id.btnJsonArray);
      msgResponse = (TextView) findViewById(R.id.msgResponse);
  
      pDialog = new ProgressDialog(this);
      pDialog.setMessage("Loading...");
      pDialog.setCancelable(false);
  
      btnJsonObj.setOnClickListener(this);
      btnJsonArray.setOnClickListener(this);
  }
  
  private void showProgressDialog() {
      if (!pDialog.isShowing())
          pDialog.show();
  }
  
  private void hideProgressDialog() {
      if (pDialog.isShowing())
          pDialog.hide();
  }
  
  /**
   * Making json object request
   * */
  private void makeJsonObjReq() {
      showProgressDialog();
      JsonObjectRequest jsonObjReq = new JsonObjectRequest(Method.GET,
              Const.URL_JSON_OBJECT, null,
              new Response.Listener&lt;JSONObject&gt;() {
  
                  @Override
                  public void onResponse(JSONObject response) {
                      Log.d(TAG, response.toString());
                      msgResponse.setText(response.toString());
                      hideProgressDialog();
                  }
              }, new Response.ErrorListener() {
  
                  @Override
                  public void onErrorResponse(VolleyError error) {
                      VolleyLog.d(TAG, "Error: " + error.getMessage());
                      hideProgressDialog();
                  }
              }) {
  
          /**
           * Passing some request headers
           * */
          @Override
          public Map&lt;String, String&gt; getHeaders() throws AuthFailureError {
              HashMap&lt;String, String&gt; headers = new HashMap&lt;String, String&gt;();
              headers.put("Content-Type", "application/json");
              return headers;
          }
  
          @Override
          protected Map&lt;String, String&gt; getParams() {
              Map&lt;String, String&gt; params = new HashMap&lt;String, String&gt;();
              params.put("name", "Androidhive");
              params.put("email", "abc@androidhive.info");
              params.put("pass", "password123");
  
              return params;
          }
  
      };
  
      // Adding request to request queue
      AppController.getInstance().addToRequestQueue(jsonObjReq,
              tag_json_obj);
  
      // Cancelling request
      // ApplicationController.getInstance().getRequestQueue().cancelAll(tag_json_obj);       
  }
  
  /**
   * Making json array request
   * */
  private void makeJsonArryReq() {
      showProgressDialog();
      JsonArrayRequest req = new JsonArrayRequest(Const.URL_JSON_ARRAY,
              new Response.Listener&lt;JSONArray&gt;() {
                  @Override
                  public void onResponse(JSONArray response) {
                      Log.d(TAG, response.toString());
                      msgResponse.setText(response.toString());
                      hideProgressDialog();
                  }
              }, new Response.ErrorListener() {
                  @Override
                  public void onErrorResponse(VolleyError error) {
                      VolleyLog.d(TAG, "Error: " + error.getMessage());
                      hideProgressDialog();
                  }
              });
  
      // Adding request to request queue
      AppController.getInstance().addToRequestQueue(req,
              tag_json_arry);
  
      // Cancelling request
      // ApplicationController.getInstance().getRequestQueue().cancelAll(tag_json_arry);
  }
  
  @Override
  public void onClick(View v) {
      switch (v.getId()) {
      case R.id.btnJsonObj:
          makeJsonObjReq();
          break;
      case R.id.btnJsonArray:
          makeJsonArryReq();
          break;
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>And this is the URL I am using</p>
  
  <pre><code>http://api.androidhive.info/volley/person_array.json
  </code></pre>