title: How to pass intent with Adapter in Kotlin
body: <p>I would like to pass intent to another activity class with Adapter via OnClick function in Kotlin. However, when I am using the debug function, I noticed that the intent has not passed successfully. May I know how can I solve this? From various sources online, I realized that I may be required to called the gList inside the &quot;OnClick&quot; function, but I cant seem to work it out.</p>
  <pre><code>class GoalAdapter(
  private var gList: ArrayList&lt;GoalList&gt;
  ) : RecyclerView.Adapter&lt;GoalAdapter.MyViewHolder&gt;(), View.OnClickListener{
  
  private var connection : Connection? = null
  private var statement : Statement? = null
  
  override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): MyViewHolder {
      val v: View = LayoutInflater.from(parent.context).inflate(R.layout.activity_goal_list, parent, false)
      return MyViewHolder(v)
  
  }
  
  override fun getItemCount(): Int {
      return gList.size
  }
  
  
  override fun onBindViewHolder(holder: MyViewHolder, position: Int) {
      val list = gList[position]
      holder.goal.text = list.gName
      holder.tAmount.text = list.tAmount.toString()
      holder.sAmount.text = list.sAmount.toString()
      holder.gnote.text = list.Note
      holder.gdate.text = list.dDate
  
      val sqlCon = SQLCon()
      connection = sqlCon.connectionClass()!!
  
      holder.delete.setOnClickListener {
          try
          {
              val sql : String= &quot;DELETE FROM Goals where gName = '${list.gName}' &quot;
              statement = connection!!.createStatement()
              statement!!.executeQuery(sql)
  
          }
          catch (e : Exception)
          { }
      }
  
      holder.update.setOnClickListener(this)
  }
  
  class MyViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
      var goal: TextView = itemView.findViewById(R.id.txtGoal)
      var tAmount : TextView = itemView.findViewById(R.id.txtTargetAmount)
      var sAmount : TextView = itemView.findViewById(R.id.txtSavedAmount)
      var gnote : TextView = itemView.findViewById(R.id.txtNote)
      var gdate : TextView = itemView.findViewById(R.id.txtDate)
      var delete : Button = itemView.findViewById(R.id.btnDeleteGoal)
      var update : Button = itemView.findViewById(R.id.btnUpdateGoal)
  
  }
  
  override fun onClick(view: View?) {
      when(view?.id)
      {
          R.id.btnUpdateGoal -&gt;
          {
              val intent = Intent(view.context, EditGoalActivity::class.java)
              intent.putExtra(&quot;gName&quot;, R.id.txtGoal)
              intent.putExtra(&quot;tAmount&quot;, R.id.txtTargetAmount )
              intent.putExtra(&quot;sAmount&quot;, R.id.txtSavedAmount )
              intent.putExtra(&quot;Note&quot;, R.id.txtNote )
              intent.putExtra(&quot;dDate&quot;, R.id.txtDate )
              view.context.startActivity(intent)
          }
  
      }
  }
  </code></pre>
  <p>}</p>