android 双向绑定无法为 kotlinx.coroutines.flow.MutableStateFlow 解析 setter
android Two-way binding cannot resolve a setter for kotlinx.coroutines.flow.MutableStateFlow
尝试使用数据绑定将应用程序切换到 stateflow 但出现错误
双向绑定无法为 kotlinx.coroutines.flow.MutableStateFlow
解析 setter
xml
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/notificationsSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="@={viewModel.enable}"
android:layout_gravity="center_vertical"
android:theme="@style/Switch" />
代码
val enable = MutableStateFlow(true)
我在 gradle
中启用了数据绑定
buildFeatures {
dataBinding true
}
liveData 工作正常但想为流删除它
您可能需要将 gradle 版本升级到 7.0+,如此处所述:https://youtu.be/JnN6EFZ6DO8?t=933
尝试使用数据绑定将应用程序切换到 stateflow 但出现错误
双向绑定无法为 kotlinx.coroutines.flow.MutableStateFlow
解析 setterxml
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/notificationsSwitch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="@={viewModel.enable}"
android:layout_gravity="center_vertical"
android:theme="@style/Switch" />
代码
val enable = MutableStateFlow(true)
我在 gradle
中启用了数据绑定buildFeatures {
dataBinding true
}
liveData 工作正常但想为流删除它
您可能需要将 gradle 版本升级到 7.0+,如此处所述:https://youtu.be/JnN6EFZ6DO8?t=933