I've found a tutorial on how to implement onClickListener
to RecyclerView
but then I couldn't find out why the code doesn't work. The log says that the lateinit property has not been initialized. I am not sure why it said that. How would I be able to solve this?
This is part of the code in MainActivity:
viewManager = LinearLayoutManager(this)
val list = ArrayList<test>()
recyclerView = findViewById<RecyclerView>(R.id.recyclerview).apply {
setHasFixedSize(true)
layoutManager = viewManager
adapter = ListAdapter(list)
}
ListAdapter(list).setOnItemClickListener(object : ListAdapter.ClickListener {
override fun onClick(pos: Int, aView: View) {
Toast.makeText(applicationContext,"It works :)",Toast.LENGTH_SHORT).show()
}
})