不能取消引用 int。数据绑定二元运算符

int cannot be dereferenced. Databinding binary operators

当我尝试使用数据绑定在布局中使用二元运算符设置标志时,出现 "int cannot be dereferenced" 错误。

<layout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/tools">

    <data>
        <variable
            name="textState"
            type="java.lang.Integer"/>
    </data>
        <android.support.v7.widget.AppCompatCheckBox
            android:id="@+id/checkbox"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Text"
            app:paintFlags="@{checkbox.getPaintFlags() | textState.intValue()}"/>
</layout>

二进制操作数的 checkbox.getPaintFlags() | textState.intValue() 顺序被解释为 ((int)checkbox).getPaintFlags(),这是错误的原因。

但是!如果您反转操作数的顺序,它会正确解释。并且有效!

当我发现这个功能时我很纳闷