title: How to get a text from EditText?
body: <p>I make <code>DialogFragment</code> with custom <code>layout</code> and set this such way</p>
  
  <pre><code>AlertDialog.Builder adb = new AlertDialog.Builder(getActivity())
          .setView(layout)
          .setCancelable(true);
  </code></pre>
  
  <p>This <code>layout</code> which was set in <code>DialogFragment</code> contains <code>EditText</code>. Gist in fact that when <code>DialogFragment</code> appear, user have to enter in <code>EditText</code> your comment and then push button <code>send</code>.</p>
  
  <p>It was a problem when i tried <code>findViewById()</code> , because <code>DialogFragment</code> didn't extend <code>Activity</code>, thus i try solve this issue such way :</p>
  
  <pre><code>LayoutInflater inflater = getActivity().getLayoutInflater();
  View view = inflater.inflate(R.layout.activity_note_dialog, null);
  EditText etNoteFromWeb = (EditText)view.findViewById(R.id.etNoteFromWeb);
  String response = etNoteFromWeb.getText().toString();
  </code></pre>
  
  <p>But <code>etNoteFromWeb.getText().toString();</code> everytime give me back empty line, not <code>null</code>... Actually empty line.</p>
  
  <p><strong>What i am doing wrong?</strong></p>
  
  <p>Here is full code of <code>DialogFragment</code> : </p>
  
  <p>public class MyDialog extends DialogFragment {</p>
  
  <pre><code>final String LOG_TAG = "MyDialog";
  private static MyDialog myDialog;
  private EditText etNoteFromWeb;
  
  int layout;
  
  @Override
  public void onCreate(Bundle savedState) {
      super.onCreate(savedState);
      Bundle args = this.getArguments();
      layout = args.getInt("layout");
  }
  
  public Dialog onCreateDialog(Bundle savedInstanceState) {
  
      AlertDialog.Builder adb = new AlertDialog.Builder(getActivity())
              .setView(layout)
              .setCancelable(true);
  
      if (layout == R.layout.activity_note_dialog) {
  
          LayoutInflater inflater = getActivity().getLayoutInflater();
  
          View view = inflater.inflate(layout, null);
  
          LinearLayout llSent = (LinearLayout) view.findViewById(R.id.llSent);
          LinearLayout llSkip = (LinearLayout) view.findViewById(R.id.llSkip);
  
          llSent.setOnClickListener(listener);
          llSkip.setOnClickListener(listener);
          adb.setView(view);
      }
  
      return adb.create();
  }
  
  View.OnClickListener listener = new View.OnClickListener() {
      @Override
      public void onClick(View v) {
  
          if (layout == R.layout.activity_note_dialog) {
  
              LayoutInflater inflater = getActivity().getLayoutInflater();
              View view = inflater.inflate(R.layout.activity_note_dialog, null);
              etNoteFromWeb = (EditText) view.findViewById(R.id.etNoteFromWeb);
              String response = etNoteFromWeb.getText().toString();
  //                String response = "etNoteFromWeb.getText().toString()";
              // Здесь в System.out.println ничего нет...9(( но когда раскоментирована строка 
              // выше и указываю статический текст, то все работает, проблема именно в том, 
              // что не достает текст из EditText
              System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " + response);
              switch (v.getId()) {
                  case R.id.llSent:
                      onClick.onDialogClickListener(response);
                      myDialog.dismiss();
                      break;
                  case R.id.llSkip:
                      onClick.onDialogClickListener(null);
                      myDialog.dismiss();
                      break;
              }
          }
      }
  };
  
  public void dismissDialog(final MyDialog dialog, int daleyTime) {
      Handler handler = new Handler();
      handler.postDelayed(new Runnable() {
          @Override
          public void run() {
              try {
                  dialog.dismiss();
              } catch (IllegalStateException e) {
                  e.printStackTrace();
              }
          }
      }, daleyTime);
  }
  
  public void onDismiss(DialogInterface dialog) {
      super.onDismiss(dialog);
      Log.d(LOG_TAG, "MyDialog: onDismiss");
  }
  
  public void onCancel(DialogInterface dialog) {
      super.onCancel(dialog);
      Log.d(LOG_TAG, "MyDialog: onCancel");
  }
  
  public static MyDialog newInstance(int layout) {
      myDialog = new MyDialog();
  
      Bundle args = new Bundle();
      args.putInt("layout", layout);
      myDialog.setArguments(args);
  
      return myDialog;
  }
  
  
  //  Этот интерфейс я реализовал для того чтоб можно было передавать данные из DialogFragment
  public interface OnButtonClick {
      void onDialogClickListener(String response);
  }
  
  OnButtonClick onClick;
  
  @Override
  public void onAttach(Activity activity) {
      super.onAttach(activity);
  
      try {
          onClick = (OnButtonClick) activity;
      } catch (ClassCastException e) {
          throw new ClassCastException(activity.toString() + " must implement onDialogClickListener");
      }
  }
  
  @Override
  public void onDetach() {
      super.onDetach();
      onClick = null;
  }
  }
  </code></pre>