Check out example codes for "recyclerview onclicklistener kotlin". It will help you in understanding the concepts better.

Code Example 1

val data = list[position]holder.itemView.setOnClickListener {    cellClickListener.onCellClickListener(data)}

Code Example 2

interface CellClickListener {    fun onCellClickListener(data: Model)}

Code Example 3

class MainActivity : AppCompatActivity(), CellClickListener {    override fun onCreate(savedInstanceState: Bundle?) {        super.onCreate(savedInstanceState)        setContentView(R.layout.activity_main)        val recyclerView: RecyclerView = findViewById(R.id.recycler_view)        recyclerView.layoutManager = LinearLayoutManager(this)        recyclerView.adapter = Adapter(this, fetchList(), this)    }    private fun fetchList(): ArrayList<Model> {        val list = arrayListOf<Model>()        for (i in 0..9) {            val model = Model(R.drawable.ic_collections_black_24dp, "Title : $i", "Subtitle : $i")            list.add(model)        }        return list    }    override fun onCellClickListener() {        Toast.makeText(this,"Cell clicked", Toast.LENGTH_SHORT).show()    }}

Learn ReactJs, React Native from akashmittal.com