title: Android - Custom Dialog - Can't get text from EditText
body: <p>I have a problem with a custom dialog. <br>
  My dialog consists of a <code>TextView</code>, <code>EditText</code> and an "Ok" Button. After clicking "Ok", it should get the text from EditText field and assign it to the String variable "name" defined in the Activity. <br>
  Everything seems to work, no errors etc, however "text" is always an empty String. <br>
  I read some topics about such problems, however I'm not really sure what adjustments I should make here. <br>
  I'm quite new to Android programming, so I'd be grateful if somebody could explain the problem to me. Thanks in advance.</p>
  
  <pre><code>     final Dialog dialog = new Dialog(MyActivity.this);
       dialog.setContentView(R.layout.custom_dialog);
       dialog.setTitle("Title");
  
       final View layout = View.inflate(this, R.layout.custom_dialog, null);
       Button button = (Button) dialog.findViewById(R.id.dialog_ok);
       button.setOnClickListener(new OnClickListener() {
           public void onClick(View v) {
                  EditText edit=(EditText)layout.findViewById(R.id.dialog_edit);
                  String text=edit.getText().toString();
  
                  name=text;
  
                  dialog.dismiss();
           }
       });   
  
       dialog.show();
  </code></pre>