SetChecked() does not work

Viewed 7777

Hey guys on my Adapter ViewHolder.bind I have to check if some value is true, then check my checkbox. The problem is I cant use setCheck(tru) cause in kotlin doesnt apear.

3 Answers

Try this

To check the Checkbox use do this

 holder.checkBox!!.isChecked=true

And to uncheck Checkbox do this

  holder.checkBox!!.isChecked=false

please use following function to solve your problem

fun setChecked(viewId: Int, checked: Boolean) {
    (findView<View>(viewId) as Checkable).isChecked = checked
}
lateinit var checkBox: CheckBox


checkBox = findViewById(R.id.notifcheckBox)
checkBox.isChecked = true
Related