I cannot seem to get around the idea if some property i.e. has_tv is empty or in other words a RadioGroup that has been left empty by user, how can I request focus to that particular view using data binding and MVVM, any help is appreciated
XML
android:id="@+id/rgHasTv"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tvTv"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="5dp"
android:onCheckedChanged="@{(radioGroup, checkedId) -> viewmodel.setTv(radioGroup, checkedId)}"
android:orientation="vertical"
android:tooltipText="">
android:id="@+id/tv_yes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Yes"
android:textSize="16dp" />
android:id="@+id/tv_no"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="No"
android:textSize="16dp" />
Kotlin
fun setTv(radioGroup: RadioGroup, checkedId: Int) {
if (checkedId == R.id.tv_yes) {
Log.d("Checked: ", "TV YES");
household.has_tv = "1";
}
if (checkedId == R.id.tv_no) {
Log.d("Checked: ", "TV NO");
household.has_tv = "2";
}
radioGroup.requestFocus()
}