title: Kotlin synthetic and custom layout in DialogFragment
body: <p>Let's say I have this layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical"&gt;
  
  &lt;ImageButton
      android:id="@+id/add_dep_btn"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentEnd="true"
      android:layout_alignParentRight="true"
      android:layout_marginEnd="5dp"
      android:layout_marginRight="5dp"
      android:src="@android:drawable/ic_input_add" /&gt;
  
  &lt;EditText
      android:id="@+id/add_dep_text"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignBottom="@id/add_dep_btn"
      android:layout_alignParentLeft="true"
      android:layout_alignParentStart="true"
      android:layout_alignTop="@id/add_dep_btn"
      android:layout_marginLeft="5dp"
      android:layout_marginStart="5dp"
      android:layout_toLeftOf="@id/add_dep_btn"
      android:layout_toStartOf="@id/add_dep_btn" /&gt;
  
  &lt;android.support.v7.widget.RecyclerView
      android:id="@+id/dep_list"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_below="@id/add_dep_btn" /&gt;
  
  &lt;TextView
      android:id="@+id/empty_text"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_below="@id/add_dep_text"
      android:layout_margin="20dp"
      android:gravity="center"
      android:text="@string/no_dep"
      android:textSize="22sp" /&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>And I use it in a DialogFragment:</p>
  
  <pre><code>class DepartmentChoiceDialog : DialogFragment() {
      override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
          val builder = AlertDialog.Builder(activity)
          builder.setTitle(R.string.choose_or_create_dep)
              .setView(R.layout.department_chooser_dialog)
              .setNegativeButton(android.R.string.cancel, { d, i -&gt;
                  d.cancel()
              })
          return builder.create()
      }
  }
  </code></pre>
  
  <p>if I refer to the widget using synthetic:</p>
  
  <pre><code>override fun onActivityCreated(savedInstanceState: Bundle?) {
      super.onActivityCreated(savedInstanceState)
      dep_list.layoutManager = LinearLayoutManager(activity)
      dep_list.itemAnimator = DefaultItemAnimator()
      dep_list.setHasFixedSize(true)
  }
  </code></pre>
  
  <p>I got this error at runtime:</p>
  
  <blockquote>
    <p>java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.view.View.findViewById(int)' on a null object reference
                                                                            at MyDialog._$_findCachedViewById(DepartmentChoiceDialog.kt:0)</p>
  </blockquote>
  
  <p>I don't understand how to use synthetic in DialogFragment case. It works fine in Fragment and Activity.</p>