title: How to start activity from adapter in kotlin android
body: <p>I have created a simple <code>Adapter</code>. I am trying to start <code>Activity</code> from within the <code>Adapter</code> when user clicks on an item. I am not able to get the <code>context</code> in the <code>onClick</code>. I am performing <code>onClick</code> inside <code>MyViewHolder</code> class. Here is my adapter code:</p>
  
  <pre><code>class LeadListAdapter(context:Context, private val leadList: List&lt;Lead&gt;) : RecyclerView.Adapter&lt;LeadListAdapter.MyViewHolder&gt;() {
      var activity:Context = context
      override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
          val inflatedView = parent.inflate(R.layout.custom_lead_row, false)
          return MyViewHolder(inflatedView)
      }
  
      override fun getItemCount(): Int {
          return leadList.size
      }
  
      override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
          holder.bindLead(leadList[position])
      }
  
      class MyViewHolder(v: View) : RecyclerView.ViewHolder(v), View.OnClickListener {
          //2
          private var view: View = v
          private var lead: Lead? = null
  
          //3
          init {
              v.setOnClickListener(this)
              v.trackButton.setOnClickListener(this)
          }
  
          //4
          override fun onClick(v: View) {
              val intent = Intent(activity) //Getting error here
          }
  
          fun bindLead(lead: Lead) {
              this.lead = lead
              view.leadName.text = lead.cusName
              view.leadMobileNumber.text = lead.mobileNo.toString()
              view.loanAmount.text = lead.amount.toString()
              view.leadId.text = "Lead Id: ${lead.id.toString()}"
              view.loanType.text = lead.productType
              view.loanTypeIcon.text = getCharsFromWords(lead.productType)
          }
  
          private fun getCharsFromWords(productType: String?): String? {
              val words = productType!!.split(Regex("\\s+"))
              val quote: String
              val sb = StringBuilder()
              for (word in words) {
                  sb.append(word[0].toString())
              }
              quote = sb.toString()
              return quote
          }
  
          companion object {
              //5
              private val LEAD_KEY = "LEAD"
          }
      }
  
  }
  </code></pre>