繁体   English   中英

ConcurrentModificationException使用数据绑定构建Android XML

[英]ConcurrentModificationException building Android XML with data binding

Error:cannot generate view binders java.util.ConcurrentModificationException ,尝试在XML中设置ObservableBoolean值时发生Error:cannot generate view binders java.util.ConcurrentModificationException

XML:

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

模型:

public ObservableBoolean useSoy = new ObservableBoolean(false);

我怎样才能解决这个问题?

我通过调用单独的setter方法使其运行。

XML:

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

模型:

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