If you are looking to do this in Kotlin with the interface implementation.
class MainActivity: AppCompatActivity(),CompoundButton.OnCheckedChangeListener{
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val yourCheckBox = findViewById<CheckBox>(R.id.check_box)
yourCheckBox.setOnCheckedChangeListener(this)
}
override fun onCheckedChanged(buttonView: CompoundButton?, isChecked: Boolean) {
when(buttonView?.id){
R.id.check_box -> Log.d("Checked: ","$isChecked")
}
}
}