我有一个单选按钮:
<RadioButton
android:id="@+id/rdioA"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:checked="@{!q.b}"
android:onCheckedChanged="@{(cb, isChecked) -> {if (isChecked) q.setB(false)}}"
android:text="AAA"/>
变量'q'的定义如下:
<data>
<import type="android.view.View"/>
<variable name="q" type="com.example.Q"/>
</data>
Q.java中的函数是:
public void setB(boolean b) {
this.b = b;
}
The compilation error i get is:
/Users/../view_d.xml
Error:(60, 53) Syntax error: extraneous input '=' expecting {<EOF>, '.', '::', '[', '+', '-', '*', '/', '%', '<<', '>>>', '>>', '<=', '>=', '>', '<', 'instanceof', '==', '!=', '&', '^', '|', '&&', '||', '?', '??'}
Error:Execution failed for task ':app:compileDevDebugJavaWithJavac'.
> java.lang.RuntimeException: Found data binding errors.
如果我使用
android:onCheckedChanged="@{q::onCheckedChanged}"
没有问题 - 它有效。