title: List view crashes when I scroll to the bottom
body: <p><a href="https://i.stack.imgur.com/YA35S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YA35S.png" alt="enter image description here"></a>I know this answer has been asked and answered on some pages such as this one ..
  <a href="https://stackoverflow.com/questions/18945623/android-app-crashes-after-scrolling-down-listview">Android App crashes after Scrolling down ListView</a></p>
  
  <p>But I tried the answer and my app still will crash and give me a null pointer exception, i cant seem to find where i should put the if statement or if i need to do something totally different heres my code </p>
  
  <pre><code>package com.evanarendssgmail.php;
  
  import android.app.AlertDialog;
  import android.app.ListActivity;
  import android.content.Intent;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.View;
  import android.widget.ArrayAdapter;
  import android.widget.EditText;
  
  import com.android.volley.RequestQueue;
  import com.android.volley.Response;
  import com.android.volley.toolbox.Volley;
  
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  
  public class MainActivity extends ListActivity {
  
  
      private EditText name;
      private EditText buzz;
      private String [] names;
      private JSONObject jsonResponse;
      private String [] newNames;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          String [] evan = new String[10];
          for (int i = 0; i &lt; 10; i ++) {
              evan[i] = "evan";
          }
          jsonResponse = null;
  
          Response.Listener&lt;String&gt; responseListener = new Response.Listener&lt;String&gt;() {
              @Override
              public void onResponse(String response) {
                  String TAG = "YOUR TAG";
                  Log.d(TAG,"after onResponse");
                  try {
  
                      Log.d(TAG,"after try");
                      jsonResponse = new JSONObject(response);
                      Log.d(TAG,"after object initialization");
                      boolean success = jsonResponse.getBoolean("success");
                      Log.d(TAG,"after boolean statement");
                      if (success) {
                          Log.d(TAG,"Sucess");
                          //jarray = jsonResponse.getJSONArray("name");
                          if (jsonResponse != null) {
                              String lengt = Integer.toString(jsonResponse.length());
                              Log.d(TAG, "after lengt intialization");
                              int length = Integer.parseInt(lengt);
                              Log.d(TAG, "After length initialization");
                              names = new String[length];
                              Log.d(TAG, "after array initialization");
                              String number = "";
                              for (int i = 0; i &lt; length - 1; i++) {
                                  Log.d(TAG, "beginning loop");
                                  number = Integer.toString(i);
                                  Log.d(TAG, "mid loop");
                                  names[i] = jsonResponse.getString(number);
                                  Log.d(TAG, "End loop");
                              }
                          }
                          Log.d(TAG,"Before array adapter");
                          Log.d(TAG,"End of Tag");
  
  
                      } else {
                          AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                          builder.setMessage("Login Failed")
                                  .setNegativeButton("Retry", null)
                                  .create()
                                  .show();
                      }
  
                  } catch (JSONException e) {
                      Log.d(TAG,"catch");
                      e.printStackTrace();
                  }
              }
          };
  
          LoginRequest loginRequest = new LoginRequest(responseListener);
          RequestQueue queue = Volley.newRequestQueue(MainActivity.this);
          queue.add(loginRequest);
  
          //trnsfer();
  
          ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(getListView().getContext(),android.R.layout.simple_list_item_1,names);
          getListView().setAdapter(adapter);
  
  
  
  
          name = (EditText) findViewById(R.id.name_text);
          buzz = (EditText) findViewById(R.id.buzz_text);
      }
  
  
      public void trnsfer() {
  
      }
      public void send_click(View v) {
          String nme = name.getText().toString();
  
          Response.Listener&lt;String&gt; responseListener = new Response.Listener&lt;String&gt;() {
              @Override
              public void onResponse(String response) {
                  try {
                      JSONObject jsonResponse = new JSONObject(response);
                      boolean success = jsonResponse.getBoolean("success");
                      if (success) {
                          Intent intent = new Intent(MainActivity.this, MainActivity.class);
                          MainActivity.this.startActivity(intent);
                      } else {
                          AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                          builder.setMessage("Register Failed")
                                  .setNegativeButton("Retry", null)
                                  .create()
                                  .show();
                      }
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
              }
          };
  
          RegisterRequest registerRequest = new RegisterRequest(nme, responseListener);
          RequestQueue queue = Volley.newRequestQueue(MainActivity.this);
          queue.add(registerRequest);
      }
  
      public void reap() {
          Response.Listener&lt;String&gt; responseListener = new Response.Listener&lt;String&gt;() {
              @Override
              public void onResponse(String response) {
                  String TAG = "YOUR TAG";
                  Log.d(TAG,"after onResponse");
                  try {
                      Log.d(TAG,"after try");
                      JSONObject jsonResponse = new JSONObject(response);
                      Log.d(TAG,"after object initialization");
                      boolean success = jsonResponse.getBoolean("success");
                      Log.d(TAG,"after boolean statement");
                      if (success) {
                          Log.d(TAG,"Sucess");
                          //jarray = jsonResponse.getJSONArray("name");
                          String lengt = Integer.toString(jsonResponse.length());
                          Log.d(TAG,"after lengt intialization");
                          int length = Integer.parseInt(lengt);
                          Log.d(TAG,"After length initialization");
                          names = new String[length];
                          Log.d(TAG,"after array initialization");
                          String number = "";
                          for (int i = 0; i &lt; length - 1; i ++ ) {
                              Log.d(TAG,"beginning loop");
                              number = Integer.toString(i);
                              Log.d(TAG,"mid loop");
                              names[i] = jsonResponse.getString(number);
                              Log.d(TAG,"End loop");
                          }
                          Log.d(TAG,"Before array adapter");
                          Log.d(TAG,"End of Tag");
  
  
                      } else {
                          AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                          builder.setMessage("Login Failed")
                                  .setNegativeButton("Retry", null)
                                  .create()
                                  .show();
                      }
  
                  } catch (JSONException e) {
                      Log.d(TAG,"catch");
                      e.printStackTrace();
                  }
              }
          };
  
          LoginRequest loginRequest = new LoginRequest(responseListener);
          RequestQueue queue = Volley.newRequestQueue(MainActivity.this);
          queue.add(loginRequest);
  
      }
  }
  </code></pre>
  
  <p>---XML FILES</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context="com.evanarendssgmail.php.MainActivity"&gt;
  
  
      &lt;ListView
          android:layout_width="wrap_content"
          android:layout_height="250dp"
          android:id="@android:id/list"
          android:layout_below="@+id/buzz_text"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true" /&gt;
  
      &lt;EditText
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/name_text"
          android:layout_alignParentTop="true"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"
          android:layout_alignRight="@android:id/list"
          android:layout_alignEnd="@android:id/list"
          android:text="Name" /&gt;
  
      &lt;EditText
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/buzz_text"
          android:layout_below="@+id/name_text"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true"
          android:layout_alignRight="@+id/name_text"
          android:layout_alignEnd="@+id/name_text"
          android:text="buzzword" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Send"
          android:id="@+id/button"
          android:onClick="send_click"
          android:layout_below="@android:id/list"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Receve"
          android:onClick="receve_click"
          android:id="@+id/button2"
          android:layout_below="@+id/button"
          android:layout_alignParentLeft="true"
          android:layout_alignParentStart="true" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>It will load all the data into the listview if i put the response listener into a onclick function but then once i scroll to the bottom it will give me a null pointer exception. </p>