title: Can I defer the view binding in an adapter using Kotlin Android Extension
body: <p>Kotlin Android Extensions provide a way that using the IDs directly in Activity/fragment/Adapters.
  So What I want is a generic way for an adapter and leave the bind view responsibility to the user of adapter instead of adapter itself.
  For example :</p>
  
  <pre><code>class GenericAdapter&lt;T&gt;(
      @LayoutRes private val layoutId: Int,
      private var list: List&lt;T&gt;,
      inline private val bind: (View, T, Int) -&gt; Unit) : RecyclerView.Adapter&lt;InnerHolder&gt;() {
      override fun onBindViewHolder(holder: InnerHolder?, position: Int) {
          holder?.containerView?.let {
               bind(holder.containerView, list[position], position)
          }
      }
  
      override fun onCreateViewHolder(parent: ViewGroup?, viewType: Int): InnerHolder =
          InnerHolder(LayoutInflater.from(parent?.context).inflate(layoutId,
              parent,
              false))
  
      override fun getItemCount(): Int = list.size
  
      class InnerHolder(
          val containerView: View?) : RecyclerView.ViewHolder(containerView)
  
  }
  </code></pre>
  
  <p>which I can just pass the layout file and bind function to bind the adapter as I want without rewriting the same code for every single layout file with and adapter.</p>
  
  <p>But here is the problem:
  ViewHolder pattern want to eliminate call "findViewById" every time an ChildView inflated. But with my implementation of adapter. It needs to call "findViewById" every time when adapter bind a view.</p>
  
  <p>Edit: for the details of the "cache" problem.</p>
  
  <p>Using the <code>GenericAdapter</code> in Activity. Like </p>
  
  <pre><code>override fun onCreated(savedInstanceState: Bundle?){
      list.adapter = GenericAdapter&lt;Item&gt;(items){ view,item,position -&gt;
          view.textview.text = item.text
      }
  }
  </code></pre>
  
  <p>this will decompiled into this:</p>
  
  <pre><code>     TextView var2 = (TextView)var10000.findViewById(id.textview);
       Intrinsics.checkExpressionValueIsNotNull(var2, "itemView.tv_text");
       var2.setText((CharSequence)String.valueOf(var1));
  </code></pre>
  
  <p>But they have a experimental tool with Android Extension with a <code>LayoutContainer</code> for example :</p>
  
  <pre><code>class InnerHolder(
      override val containerView: View?) : RecyclerView.ViewHolder(containerView), LayoutContainer {
      fun bind(int: Int) {
          textview.text = int.toString()
      }
  }
  </code></pre>
  
  <p>And this will perfectly use the cached views: </p>
  
  <pre><code>     TextView var10000 = (TextView)this._$_findCachedViewById(id.tv_text);
  </code></pre>
  
  <p>But the problem is that the cached views need inside the scope of LayoutContainer. For example this implementation wont work:</p>
  
  <pre><code>class InnerHolder(
      override val containerView: View?) : RecyclerView.ViewHolder(containerView), LayoutContainer {
      fun bind(int: Int) {
          this.bindInt(int)
      }
  
  }
  // some extension function outside the ViewHolder Scope. 
  fun LayoutContainer.bindInt(int: Int) {
      tv_text.text = int.toString()
  
  }
  </code></pre>
  
  <p>this will still use the findViewById to find the view: </p>
  
  <pre><code>  TextView var10000 = (TextView)$receiver.getContainerView().findViewById(id.tv_text);
  </code></pre>
  
  <p>So my question is there a way to remain the cache in some way and still using Android Extension with my adapter but outside the scope of viewholder?</p>