title: Getting a user String in a dialog popup
body: <p>In my Android code, I inflate the GUI and store all the sub-elements in a different class. In that class, I want to add a method to read a user input from. I tried to follow something like in this <a href="https://stackoverflow.com/questions/3968170/Android-prompt-users-input-using-a-dialog">link</a> but no matter what I do, it boils down into copying a final value into a non final value. I though about creating another gui but couldn't fins a way to do so. Here is the method I have now:</p>
  
  <pre><code>private String setText(int id){
          AlertDialog.Builder alert = new AlertDialog.Builder(this.show);
          final EditText input = new EditText(this.show);
          alert.setView(input);
          String out;
          alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
              //@Override
              public void onClick(DialogInterface dialog, int which) {
                  Editable value = input.getText();
                  out = value.toString();
                  // TODO Auto-generated method stub
  
              }
          });
  
      }
  }
  </code></pre>
  
  <p>Which I use to return a string into another method which set the value of the <code>TextView</code>.</p>
  
  <hr>
  
  <p>I tried to do the following trick:</p>
  
  <pre><code>private String setText(){
  
      AlertDialog.Builder alert = new AlertDialog.Builder(this.show);
      final EditText input = new EditText(this.show);
      alert.setView(input);
      String out;
      alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
  
          @Override
          public void onClick(DialogInterface dialog, int which) {
              input.setText("canceled");
          }
      });
      alert.setPositiveButton("OK", new DialogInterface.OnClickListener() {
  
          @Override
          public void onClick(DialogInterface dialog, int which) {
  
  
          }
      });
      alert.show();
      String toSend = input.getText().toString();
      this.maxT.setText(toSend);
      return toSend;
  </code></pre>
  
  <p><code>maxT</code> is a <code>TextView</code> field. The app simply place an empty string. I figure that I should wait until the <code>AlertDialog</code> is closed, I'm searching for a way to do so.</p>