Search code examples
androidandroid-studiolistviewkotlinonclicklistener

Checkbox on a listView prevents event click, kotlin


Using kotlin

Hi, I'm doing a listview with title, description and a checkbox.

Without the checkbox, when I click the cell, it opens a detailsActivity about the item.

So I have added a checkbox, with its default check action to make the user capable of select items, and it seems like it is preventing the view click event.

  listView.onItemClickListener = AdapterView.OnItemClickListener { adapterView, view, position, id ->
        val productListToDetail = Intent(this, ProductDetailActivity::class.java)
        productListToDetail.putExtra("title",platoList[position].nombre)
        productListToDetail.putExtra("descripcion",platoList[position].descripcion)
        startActivity(productListToDetail)
    }

Any idea?


Solution

  • Add these properties to your CheckBox:

    android:focusable="false"
    android:focusableInTouchMode="false"