Home > Mobile >  kotlin Pass multiple values on CheckChanged using databinding
kotlin Pass multiple values on CheckChanged using databinding

Time:11-15

In Kotlin checkbox from XML databinding I want to pass 3 arguments checked or not (Boolean) and Two Strings.

Currently I am passing as below

 android:onCheckedChanged="@{(switch, checked) -> availMasterVm.onCheckedChangedMondayMrng(checked)}"

when I add String I am getting error how to pass strings to the viewmodel method

CodePudding user response:

You can pass the extra parameters in just the usual way. Just remember that for strings you need to use back-ticks(``) instead of double quotes("").

 android:onCheckedChanged="@{(switch, checked) -> availMasterVm.onCheckedChangedMondayMrng(checked, `Monday`, `Morning`)}"
  • Related