title: Kotlin: How can an inner class get access to a variable declared as a parameter in an outer class?
body: <p>I have a <code>DetailAdapter</code> class with a parameter <code>categoryId</code> of type <code>String</code>. I need access to this variable in the inner class <code>DetailHolder</code>. I get the following error:</p>
  
  <blockquote>
    <p>Unresolved reference: categoryId</p>
  </blockquote>
  
  <p>How can I solve this?</p>
  
  <pre><code>class DetailAdapter(lifecycleOwner: LifecycleOwner, categoryId: String) : FirebaseRecyclerAdapter&lt;Detail, DetailAdapter.DetailHolder&gt;(DetailAdapter.buildOptions(lifecycleOwner, categoryId)) {
  
  companion object {
      private fun buildQuery(categoryId: String) = FirebaseDatabase.getInstance()
              .reference
              .child("").child("details").child(categoryId)
              .limitToLast(50)
  
      private fun buildOptions(lifecycleOwner: LifecycleOwner, categoryId: String) = FirebaseRecyclerOptions.Builder&lt;Detail&gt;()
              .setQuery(buildQuery(categoryId), Detail::class.java)
              .setLifecycleOwner(lifecycleOwner)
              .build()
  }
  
  class DetailHolder(val customView: View, var detail: Detail? = null) : RecyclerView.ViewHolder(customView) {
      private val TAG = DetailHolder::class.java.simpleName
  
      fun bind(detail: Detail) {
          with(detail) {
              customView.textView_name?.text = detail.detailName
              customView.textView_description?.text = detail.detailDescription
  
              val detailId = detail.detailId
  
              customView.setOnClickListener {
                      // do something
              }
  
              customView.setOnLongClickListener(
                      {
                          showDeleteDetailDialog(it, categoryId, detailId)
                          true
                      }
              )
          }
      }
  </code></pre>