title: The method getText() is undefined for the type ListView
body: <p>I am trying to implement a popup window where you type text and it adds it to the ListView however I am getting the following error:</p>
  
  <blockquote>
    <p>The method getText() is undefined for the type ListView</p>
  </blockquote>
  
  <p>My MainActivity.java code is as follows:</p>
  
  <pre class="lang-java prettyprint-override"><code>package com.mkyong.android;
  
  import android.app.Activity;
  import android.app.AlertDialog;
  import android.content.Context;
  import android.content.DialogInterface;
  import android.os.Bundle;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.ListView;
  
  public class MainActivity extends Activity {
  
      final Context context = this;
      private Button button;
      private ListView result;
  
      public void onCreate(Bundle savedInstanceState) {
  
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
      // components from main.xml
      button = (Button) findViewById(R.id.buttonPrompt);
      result = (ListView) findViewById(R.id.listView1);
  
      // add button listener
      button.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View arg0) {
  
              // get prompts.xml view
              LayoutInflater li = LayoutInflater.from(context);
              View promptsView = li.inflate(R.layout.prompts, null);
  
              AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
                      context);
  
              // set prompts.xml to alertdialog builder
              alertDialogBuilder.setView(promptsView);
  
              final ListView userInput = (ListView) promptsView
                      .findViewById(R.id.ListTitleDialogUserInput);
  
              // set dialog message
              alertDialogBuilder
                      .setCancelable(false)
                      .setPositiveButton("Create",
                              new DialogInterface.OnClickListener() {
                                  public void onClick(DialogInterface dialog,
                                          int id) {
                                      // get user input and set it to result
                                      // edit text
                                      result.setText(userInput.getText());
                                  }
                              })
                      .setNegativeButton("Cancel",
                              new DialogInterface.OnClickListener() {
                                  public void onClick(DialogInterface dialog,
                                          int id) {
                                      dialog.cancel();
                                  }
                              });
  
              // create alert dialog
              AlertDialog alertDialog = alertDialogBuilder.create();
  
              // show it
              alertDialog.show();
  
          }
  
      });
  
  }
  
  }
  </code></pre>
  
  <p>Thanks for your assistance. </p>
  
  <p>EDIT: The code for the for prompts.xml where the ListTitleDialogUserInput is defined is as follows;</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/layout_root"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical" &gt;
  
      &lt;TextView
              android:id="@+id/textView1"
          android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="List Title: "
              android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
  
      &lt;EditText
              android:id="@+id/ListTitleDialogUserInput"
              android:layout_width="match_parent"
              android:layout_height="wrap_content" &gt;
  
              &lt;requestFocus /&gt;
      &lt;/EditText&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>