Kotlin Android- How implement CheckBox.OnCheckedChangeListener?

前端 未结 4 1601
无人共我
无人共我 2021-01-07 16:56

I am new to Kotlin. I created a fragment and implemented View.OnClickListener and CheckBox.OnCheckedChangeListener. The View.OnClickListener

4条回答
  •  南笙
    南笙 (楼主)
    2021-01-07 17:26

    Use CheckBox.OnCheckedChangeListener like:

    checkBox.setOnCheckedChangeListener { buttonView, isChecked ->
      Toast.makeText(this,isChecked.toString(),Toast.LENGTH_SHORT).show()
    }
    

    where checkBox is CheckBox ID.

提交回复
热议问题