0

I make a list in a recyclerView. I do this with a adapter class and everything works. If I click on an item I see a toast. But now I want to go to a new activity when i click on an item but that doesn't work:

    override fun onBindViewHolder(holder: Itemholder, position: Int) {
    val kiemmodel: Eigenkiemenmodel = arraylist.get(position)

    holder.iconkiem.setImageResource(kiemmodel.iconekm!!)
    holder.icontekst.text = kiemmodel.textekm

    holder.iconkiem.setOnClickListener {
        Toast.makeText(context, model.textekm, Toast.LENGTH_SHORT).show()

        val intent = Intent(context, product::class.java)
        val bundle = Bundle()
        bundle.putString("test", "test")
        intent.putExtra("kiem", model.textekm)
        startActivity(context, intent, bundle)
    }
}

The code above is from the adapter class (kotlin) and the toast works. But when I add the code to start a new activity (and remove the toast) I get this error that startActivity needed a context and a bundle. So I added it but now when I click on an item, the screen turn white for a second and then the app crashes. Does anyone know what I can do to fix this?

chrispsv
  • 503
  • 1
  • 3
  • 21

0 Answers0