title: view.findViewById(....) always return null in dialog
body: <p>I have a dialog where I wish to force the user to fill in a name into an EditText, if it's empty I wish for pressing done to have no effect. However, </p>
  
  <pre><code>EditText x = (EditText) view.findViewById(R.id.name);
  </code></pre>
  
  <p>always returns null. I have tried searching but have only found the solution to add a view to findViewById(...) but I already have that. My guess it that it has to do with me creating my own version of the button.</p>
  
  <p>This is the code for the Dialog.</p>
  
  <pre><code>package com.example.dialogruta;
  
  
  @SuppressLint({ "NewApi", "ValidFragment" })
  public class RecordDialog extends DialogFragment {
  
  
  public  Dialog onCreateDialog(Bundle savedInstanceState) {
  
      AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
      LayoutInflater inflater = getActivity().getLayoutInflater();
      final View view = inflater.inflate(R.layout.record_fragment, null);
      builder.setView(view).setPositiveButton("Save experiment", null); //Creating my own 
  
      final Dialog d = builder.create();
      d.setOnShowListener(new DialogInterface.OnShowListener() {
  
          @Override
          public void onShow(DialogInterface dialog) {
  
              Button b = ((AlertDialog) d).getButton(AlertDialog.BUTTON_POSITIVE);
              b.setOnClickListener(new View.OnClickListener() {
  
                  @Override
                  public void onClick(View view) {
                      EditText x = (EditText) view.findViewById(R.id.name);
                      if( x!= null &amp;&amp; !x.toString().isEmpty()){
                          String xs = x.getText().toString();
                          d.dismiss();
                      }
                      else{
                          //TODO: Stuff
                      }
                  }
              });
          }
      });
  
      return d;
  }
  
  
  }
  </code></pre>
  
  <p>And this is the .xml-file</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" &gt;
  
  
          &lt;EditText
      android:id="@+id/name"
      android:inputType="text"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginTop="16dp"
      android:layout_marginLeft="4dp"
      android:layout_marginRight="4dp"
      android:layout_marginBottom="4dp"
      android:hint="Experiment name" /&gt;
  
          &lt;EditText
      android:id="@+id/notes"
      android:inputType="textMultiLine"
      android:layout_width="match_parent"
      android:layout_height="200dip"
      android:layout_weight ="1"
      android:lines="5"
      android:minLines="1"
      android:gravity="top|left"
      android:maxLines="10"
      android:layout_marginTop="16dp"
      android:layout_marginLeft="4dp"
      android:layout_marginRight="4dp"
      android:layout_marginBottom="4dp"
      android:hint="Notes" /&gt;
  
   &lt;/LinearLayout&gt;
  </code></pre>