title: Android - retrieving text input from an alertbuilder dialog
body: <p>I've got a View defined in an xml file. It contains two Edittext fields (amongt other things like text)</p>
  
  <p>I use an AlertBuilder to trigger a dialog where a user enters text(such as username and pass) into both edittext fields. When I try to retrieve the strings and send them to Login(), both strings are just null. What is going on?</p>
  
  <p>It seems like somehow the string data isn't saved?</p>
  
  <p>Here's when I show the Dialog in my app:</p>
  
  <pre><code>SignInDialog.show(ScreenMain.this, 
                                  "Login", 
                                  new DialogInterface.OnClickListener() {
                                      @Override
                                      public void onClick(DialogInterface dialog, int which) {
  
                                          LayoutInflater inflater = (LayoutInflater) ScreenMain.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                                          View layout = inflater.inflate(R.layout.screen_dialog_login, null);
                                          LogIn(((EditText) layout.findViewById(R.id.screen_dialog_login_username_edit)).getText().toString(),
                                                          ((EditText) layout.findViewById(R.id.screen_dialog_login_password_edit)).getText().toString());
  
                                      }
                                  }, 
                                  "Cancel", 
                                  new DialogInterface.OnClickListener() {
                                      @Override
                                      public void onClick(DialogInterface dialog, int which) {
                                          dialog.cancel();
                                      }
                                  });
  </code></pre>
  
  <p>Here's a class I use to instantiate a Dialog:</p>
  
  <pre><code>/* login dialog*/
  static class SignInDialog {
  
      public static void show(Context context, String positiveText, DialogInterface.OnClickListener positive, String negativeText, DialogInterface.OnClickListener negative){
          AlertDialog.Builder builder;
  
          LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          View layout = inflater.inflate(R.layout.screen_dialog_login, null);
  
          builder = new AlertDialog.Builder(context);
          builder.setView(layout);
          if(positive != null &amp;&amp; positiveText != null){
              builder.setPositiveButton(positiveText, positive);
          }
          if(negative != null &amp;&amp; negativeText != null){
              builder.setNegativeButton(negativeText, negative);
          }
  
          builder.create().show();
  
      }
  }
  </code></pre>