title: EditText field in AlertDialog not working
body: <p>I'm new to android, trying to build a simple app involving some simple data input and management. When I follow the guide <a href="http://www.mkyong.com/android/android-prompt-user-input-dialog-example/" rel="nofollow">here</a>, which ask for user input through an alert dialog. Everything works fine except that, after the AlertDialog appears, the <code>EditText</code> field does not have an input cursor displayed, and it won't display/update the text I typed. However, I can obtain the text string I typed in correctly after I pressed the 'OK' button in the alert dialog. Here is the xml file and code involving that dialog:</p>
  
  <p>xml:</p>
  
  <pre><code>&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"
  android:padding="10dp" &gt;
  
  &lt;TextView
      android:id="@+id/textView2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Type Your Message : "
      android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
  
  &lt;EditText
      android:id="@+id/grade_in"
      android:inputType="text"
      android:layout_width="match_parent"
      android:layout_height="wrap_content" &gt;
  
  &lt;/EditText&gt;
  </code></pre>
  
  <p></p>
  
  <p>code:</p>
  
  <pre><code>Button grade_in = button;
  
    grade_in.setTag(tag);
    grade_in.setOnClickListener(new OnClickListener(){
  
          public void onClick(View btn) {
  
              LayoutInflater inflater = LayoutInflater.from(activity.getApplicationContext());
              View prompt_grade_in = inflater.inflate(R.layout.grade_in, null);
  
              final EditText input_field = (EditText)prompt_grade_in.findViewById(R.id.grade_in);
  
              AlertDialog.Builder alertBuilder = new AlertDialog.Builder(activity);
  
              alertBuilder.setView(prompt_grade_in);
  
              alertBuilder.setCancelable(true)
                          .setPositiveButton("OK", 
                                  new DialogInterface.OnClickListener() {
  
                                      @Override
                                      public void onClick(DialogInterface dialog, int which) {
                                          // TODO Auto-generated method stub
                                          Log.v(null, input_field.getText().toString());
  
                                      }
                                  })
  
                          .setNegativeButton("Cancel", 
                                  new DialogInterface.OnClickListener() {
  
                                      @Override
                                      public void onClick(DialogInterface dialog, int which) {
                                          dialog.cancel();
  
                                      }
                          })
  
                          .setMessage("Grade for the course:");
  
              AlertDialog alert = alertBuilder.create();
              alert.show();
  
          }
    });
  </code></pre>
  
  <p>I tried adding a TextWatcher but it does not help. Is the version the source of this problem? Because I think I pretty much followed the guide except that I've made some minor changes. Thanks for helping!</p>
  
  <p>p.s. the page containing the button invoke the input dialog is a fragment.</p>
  
  <p><strong>UPDATE:</strong>
  The fragment containing the button consists of an <code>ExpandableListView</code>, which is implemented according to this <a href="http://www.vogella.com/tutorials/AndroidListView/article.html#listfragments" rel="nofollow">guide</a> (part 15). And the above code implementing the alert dialog is in a custom adapter class, which create the group item in the list, inside the following function:</p>
  
  <pre><code>public View getGroupView(int groupPosition, boolean isExpanded, View convertView, final ViewGroup parent) {
  
  if (convertView == null) {
    convertView = inflater.inflate(R.layout.listrow_group, null);
  }
  
  CheckedTextView checkedTextView = (CheckedTextView) convertView.findViewById(R.id.textView1);
  
  course courses = (course) getGroup(groupPosition);
  
  ((CheckedTextView) checkedTextView).setText(courses.code + " - " + courses.title);
  ((CheckedTextView) checkedTextView).setChecked(isExpanded);
  
  String tag = courses.code + " - " + courses.title;
  
  CheckBox checkbox = (CheckBox) convertView.findViewById(R.id.checkbox_course);
  checkbox.setChecked(sharedPref.getBoolean(tag, false));
  setBoxListener(checkbox, tag);
  
  Button button = (Button) convertView.findViewById(R.id.grade_button);
  setBtnListener(button, tag);
  
  return convertView;
  }
  </code></pre>