OH what the heck someone might like this
We all place edit and trashcan images in out recyclerview and would like something to happen when they are clicked. Here is our Kotlin example
This is in a card view that is inflated in the Adapter
then in the Adapter we do some binding
override fun onBindViewHolder(holder: ParentViewHolder, position: Int) {
val items = parentList[position]
holder.item.text = items.dept
holder.editCLICK.setOnClickListener {
val i = Intent(context, EnterParentActivity::class.java)
i.putExtra("FROM", "U")
i.putExtra("MainActId",items.idD)
i.putExtra("PFK",items.fkD)
i.putExtra("ET",items.dept)
i.flags = Intent.FLAG_ACTIVITY_NEW_TASK
context.startActivity(i)
}
}
inner class ParentViewHolder(view: View):RecyclerView.ViewHolder(view){
var item: TextView = view.findViewById(R.id.tvDept) as TextView
var editCLICK: RelativeLayout = view.findViewById(R.id.editCLICK) as RelativeLayout
}
Simple quick and reliable enjoy