Listview Crashes on Scroll
<p>As the title suggests, my app currently crashes when I try to scroll on a listview. Everything works as intended when the listview is opened, but as soon as i scroll down, it crashes.</p>

<p>The listview is contained within a dialog box; The code snippet below shows how i initiliaze the dialog and the array adapter:</p>

<pre><code>final Dialog startersDialog = new Dialog(context);
    startersDialog.setContentView(R.layout.starters_dialog);
    startersDialog.setTitle("Select Starter");
    convStarters = (ListView) startersDialog.findViewById(R.id.scenarios);
    greetingsAdapter = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, android.R.id.text1, chatBot.getGreetingsInputs());
    convStarters.setAdapter(greetingsAdapter);
</code></pre>

<p>Code that gets invoked when i select an item of the list:</p>

<pre><code>convStarters.setOnItemClickListener(
            new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView&lt;?&gt; adapter, View view, int position, long arg3) {
                    userInput = adapter.getItemAtPosition(position).toString();
                    System.out.println("User Input Variable is: ");
                    userInputView.setText(userInput);
                    userInputView.setFocusable(false);
                    startersDialog.dismiss();
                }
            }
    );
</code></pre>

<p>Dialog XML file:</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"&gt;

&lt;ListView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/scenarios"/&gt;
</code></pre>

<p></p>

<p>The error I'm getting is:</p>

<pre><code>02-24 16:59:16.914  17612-17612/com.example.alex.projectui E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.alex.projectui, PID: 17612
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.Object.toString()' on a null object reference
        at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:394)
        at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
        at android.widget.AbsListView.obtainView(AbsListView.java:2823)
        at android.widget.ListView.makeAndAddView(ListView.java:1884)
        at android.widget.ListView.fillDown(ListView.java:713)
        at android.widget.ListView.fillGap(ListView.java:677)
        at android.widget.AbsListView.trackMotionScroll(AbsListView.java:7040)
        at android.widget.AbsListView$FlingRunnable.run(AbsListView.java:6478)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:777)
        at android.view.Choreographer.doCallbacks(Choreographer.java:590)
        at android.view.Choreographer.doFrame(Choreographer.java:559)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:763)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:145)
        at android.app.ActivityThread.main(ActivityThread.java:5942)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:372)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)
</code></pre>

<p>I apologize if the question is rather straightforward, but I've been struggling with this problem over the past few days and I couldn't find any obvious or easy to follow resource that deals with such a problem.</p>

<p>Thanks in advance. Any response is much appreciated.</p>