Reputation: 137
I have a User data class as below and I need to use two-way data binding for the checkbox using the active variable.
data class User( var name: String, var active: Int )
android:checked="@={viewModel.user.active == 1}"
I tried this and two-way data binding does not support this. How can I fix this?
Upvotes: 0
Views: 182
Reputation: 481
Replace
android:checked="@={viewModel.user.active == 1}
TO
android:checked="@{type == 1? true : false}
Upvotes: 0