title: Kotlin Android View Binding: findViewById vs Butterknife vs Kotlin Android Extension
body: <p>I'm trying to figure out the best way to do Android View Binding in Kotlin. It seems like there are a few of options out there:</p>
  
  <p><strong>findViewById</strong></p>
  
  <pre><code>val button: Button by lazy { findViewById&lt;Button&gt;(R.id.button) }
  </code></pre>
  
  <p><strong>Butterknife</strong></p>
  
  <p><a href="https://github.com/JakeWharton/butterknife" rel="noreferrer">https://github.com/JakeWharton/butterknife</a></p>
  
  <pre><code>@BindView(R.id.button) lateinit var button: Button
  </code></pre>
  
  <p><strong>Kotlin Android Extensions</strong></p>
  
  <p><a href="https://kotlinlang.org/docs/tutorials/android-plugin.html" rel="noreferrer">https://kotlinlang.org/docs/tutorials/android-plugin.html</a></p>
  
  <pre><code>import kotlinx.android.synthetic.main.activity_main.*
  </code></pre>
  
  <p>I'm pretty familiar with findViewById and Butterknife in java land, but what are the pros and cons of each view binding approach in Kotlin? </p>
  
  <p>Does Kotlin Android Extensions play well with the RecyclerView + ViewHolder pattern?</p>
  
  <p>Also how does Kotlin Android Extensions handle view binding for nested views via <code>include</code>?</p>
  
  <p>ex: For an Activity using <code>activity_main.xml</code>, how would <code>View custom1</code> be accessed?</p>
  
  <p><strong>activity_main.xml</strong></p>
  
  <pre><code>&lt;...&gt;
      &lt;include layout="@layout/custom" android:id="@+id/custom" /&gt;
  &lt;/&gt;
  </code></pre>
  
  <p><strong>custom.xml</strong></p>
  
  <pre><code>&lt;...&gt;
      &lt;View android:id="@+id/custom1" ... /&gt;
      &lt;View android:id="@+id/custom2" ... /&gt;
  &lt;/&gt;
  </code></pre>