I am using MVVM architecture in my app and there are 4 radiobuttons in a 2*2 grid inside a radiogroup but the the problem is oncheckedChanged is not getting called in viewmodel class, here's the xml code:
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_10sdp"
android:checkedButton="@id/singleRadioBtn"
android:onCheckedChanged="@{viweModel::selectOption}"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<RadioButton
android:layout_width="0dp"
android:layout_height="@dimen/_30sdp"
android:layout_weight="1"
></RadioButton>
<Space
android:layout_width="@dimen/_8sdp"
android:layout_height="match_parent" />
<RadioButton
android:layout_width="0dp"
android:layout_height="@dimen/_30sdp"
android:layout_weight="1"
></RadioButton>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/_8sdp"
android:orientation="horizontal">
<RadioButton
android:layout_width="0dp"
android:layout_height="@dimen/_30sdp"
android:layout_weight="1"
></RadioButton>
<Space
android:layout_width="@dimen/_8sdp"
android:layout_height="match_parent" />
<RadioButton
android:layout_width="0dp"
android:layout_height="@dimen/_30sdp"
android:layout_weight="1"
></RadioButton>
</LinearLayout>
</RadioGroup>
and in viewmodel:
fun selectOption(radioGroup: RadioGroup, id: Int)
{
radioGroup.check(id)
}
But the above function is not getting called. So what I am doing wrong here? Please help!