I have a Kotlin error saying
Expected 2 parameters of types android.widget.CompoundButton!, kotlin.Boolean
The red squiggly line is at the first { in the code below:
alarmSwitch.setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener()
{
fun onCheckedChanged(buttonView: CompoundButton, isChecked: Boolean)
{
I tried:
buttonView: !CompoundButton,(says "Expecting comma or )" )buttonView: CompoundButton!,(says "Unexpected Token")buttonView!: CompoundButton,(says "Expecting comma or )" )!buttonView: CompoundButton,(says "Expecting comma or )" )buttonView: CompoundButton?,(says "Expected 2 parameters of types android.widget.CompoundButton!, kotlin.Boolean" )
The official Kotlin docs say:
Notation for Platform Types
As mentioned above, platform types cannot be mentioned explicitly in the program, so there’s no syntax for them in the language. Nevertheless, the compiler and IDE need to display them sometimes (in error messages, parameter info etc), so we have a mnemonic notation for them:
T! means “T or T?”,
(Mutable)Collection! means “Java collection of T may be mutable or not, may be nullable or not”,
Array<(out) T>! means “Java array of T (or a subtype of T), nullable or not”
I don't fully understand what the docs are saying. How would I fix this error?