'SetChecked() does not work

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.



Solution 1:[1]

please use following function to solve your problem

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

Solution 2:[2]

Try this

To check the Checkbox use do this

 holder.checkBox!!.isChecked=true

And to uncheck Checkbox do this

  holder.checkBox!!.isChecked=false

Solution 3:[3]

lateinit var checkBox: CheckBox


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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Amin Rahkan
Solution 2
Solution 3 Team chang