title: Programmatically inflated layout with Kotlin Android Extensions
body: <p>I have a following layout:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;LinearLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      xmlns:tools=&quot;http://schemas.android.com/tools&quot;
      android:layout_width=&quot;match_parent&quot;
      android:layout_height=&quot;match_parent&quot;
      android:orientation=&quot;vertical&quot;
      android:background=&quot;@android:color/white&quot;
      android:paddingLeft=&quot;20dp&quot;
      android:paddingRight=&quot;20dp&quot;&gt;
  
      &lt;TextView
          android:id=&quot;@+id/tvErrorTitle&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginTop=&quot;10dp&quot;
          android:textColor=&quot;@android:color/background_dark&quot;
          android:textSize=&quot;18sp&quot;
          /&gt;
      &lt;TextView
          android:id=&quot;@+id/tvErrorDesc&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginTop=&quot;30dp&quot;
          android:textColor=&quot;@android:color/darker_gray&quot;
          android:textSize=&quot;16sp&quot;
          /&gt;
      &lt;TextView
          android:id=&quot;@+id/tvAction&quot;
          android:layout_width=&quot;wrap_content&quot;
          android:layout_height=&quot;wrap_content&quot;
          android:layout_marginTop=&quot;30dp&quot;
          android:layout_marginBottom=&quot;10dp&quot;
          android:layout_gravity=&quot;end&quot;
          android:padding=&quot;5dp&quot;
          android:textSize=&quot;15sp&quot;
          android:textStyle=&quot;bold&quot;
          android:textAllCaps=&quot;true&quot;
          android:textColor=&quot;@android:color/holo_purple&quot;
          /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  <p>When I want to use [kotlin android extensions][1] outside of activity like below, it doesn't work. I ended up doing findViewById.</p>
  <pre><code>...
  ...
  import kotlinx.android.synthetic.main.dialog_error.*
  ...
  ...
   val view = LayoutInflater.from(context).inflate(R.layout.dialog_error, null, false)
      val tvErrorTitle = view.findViewById(R.id.tvErrorTitle) as TextView
      val tvErrorDesc = view.findViewById(R.id.tvErrorDesc) as TextView
      val tvErrorAction = view.findViewById(R.id.tvAction) as TextView
  </code></pre>
  <p>It doesn't pull the views directly from xml. How to use it in programmatically inflated layout and avoid <code>findViewById</code>?</p>
  <p><strong>Note</strong> : This question strictly belongs to [Kotlin Android Extensions][1], not the language itself.</p>
  <p><strong>Edit</strong>
  I have imported both :</p>
  <pre><code>import kotlinx.android.synthetic.main.dialog_error.view.*
  import kotlinx.android.synthetic.main.dialog_error.*
  </code></pre>
  <p>But Android Studio still tries to import from R.id and doesn't recognize those two imports. Is there anything missing?
  [1]: <a href="https://kotlinlang.org/docs/tutorials/android-plugin.html" rel="nofollow noreferrer">https://kotlinlang.org/docs/tutorials/android-plugin.html</a></p>