简体   繁体   English

ConcurrentModificationException使用数据绑定构建Android XML

[英]ConcurrentModificationException building Android XML with data binding

Error:cannot generate view binders java.util.ConcurrentModificationException occurs when trying to set an ObservableBoolean value in XML. Error:cannot generate view binders java.util.ConcurrentModificationException ,尝试在XML中设置ObservableBoolean值时发生Error:cannot generate view binders java.util.ConcurrentModificationException

XML: XML:

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Soy Milk"
    android:onClick="@{() -> model.useSoy.set(true)}"
/>

Model: 模型:

public ObservableBoolean useSoy = new ObservableBoolean(false);

How can I fix this? 我怎样才能解决这个问题?

I got it running by calling a seperate setter method. 我通过调用单独的setter方法使其运行。

XML: XML:

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Soy Milk"
    android:onClick="@{() -> model.setUseSoy(true)}"
/>

Model: 模型:

public ObservableBoolean useSoy = new ObservableBoolean(false);

public void setUseSoy(Boolean useSoy){
    this.useSoy.set(useSoy)
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM