title: Assign value to variable using popup edit text on android studio
body: <p>I'm trying to make a popup box with edit text field on Android Studio and would like to store the data entered by the user in a variable used in that class. 
  Something like this:</p>
  
  <pre><code> new AlertDialog.Builder(this)
                  .setIcon(android.R.drawable.ic_dialog_alert)
                  .setTitle("New player")
                  .setMessage("Input new player's name")
                  .setView(input)
                  .setPositiveButton("Register", new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                          name = input.getText().toString(); //&lt;---HERE !want to use this variable
                      }
                  })
                  .setNegativeButton("Cancel", null)
                  .show();
  </code></pre>
  
  <p>This doesn't work, so how could I extract the value of <code>name</code> from my popup window to use it in the main code?</p>