Android单选按钮双向数据绑定

Android单选按钮双向数据绑定,android,radio-button,android-databinding,2-way-object-databinding,two-way,Android,Radio Button,Android Databinding,2 Way Object Databinding,Two Way,我试图用两种方式将模型的布尔值绑定到RadioButton。 但是,代码不会编译。我收到以下错误消息: 错误:(41,21)错误:已定义变量receiveDataContainer 在方法onChange()中 错误:(45,59)错误:不兼容的类型:无法转换布尔值 接收数据容器 错误:(46,17)错误:不兼容的类型:ReceiveDataContainer无法 转换为布尔值 我的班级: public class ReceiveDataContainer extends BaseObserva

我试图用两种方式将模型的布尔值绑定到RadioButton。 但是,代码不会编译。我收到以下错误消息:

错误:(41,21)错误:已定义变量receiveDataContainer 在方法onChange()中

错误:(45,59)错误:不兼容的类型:无法转换布尔值 接收数据容器

错误:(46,17)错误:不兼容的类型:ReceiveDataContainer无法 转换为布尔值

我的班级:

public class ReceiveDataContainer extends BaseObservable {
    private boolean isShopReceiveMethodChosen;

    @Bindable
    public boolean isShopReceiveMethodChosen() {
        return isShopReceiveMethodChosen;
    }

    public void setShopReceiveMethodChosen(boolean isShopReceiveMethodChosen) {
        this.isShopReceiveMethodChosen = isShopReceiveMethodChosen;
        notifyPropertyChanged(BR.shopReceiveMethodChosen);
    }
}
XML:

值得一提的是,当我删除“=”符号时,代码会编译


请帮助我…

好的,我通过将类的名称从ReceiveDataContainer更改为ReceiveContainer解决了这个问题。我不知道为什么会这样,但它确实


此处的更多信息:

这取决于布局中变量名的长度。我有一些很长的名字,遇到了这个bug。缩短名称是有效的。它看起来也像是在AS 2.3中修复的
<RadioGroup
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_marginEnd="16dp"
            android:layout_marginStart="16dp"
            android:layout_marginTop="16dp"
            android:orientation="vertical"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/inputLayoutPhoneNumber">

            <RadioButton
                android:id="@+id/radio_receive_in_store"
                android:text="@string/radio_button_receive_in_store"
                android:checked="@={receiveDataContainer.shopReceiveMethodChosen}"
                style="@style/CartReceptionRadioButton" />

            <RadioButton
                android:id="@+id/radio_send_to_home"
                android:text="@string/radio_button_send_to_home"
                style="@style/CartReceptionRadioButton" />

        </RadioGroup>
// Inverse Binding Event Handlers
private android.databinding.InverseBindingListener radioReceiveInStorea = new android.databinding.InverseBindingListener() {
    @Override
    public void onChange() {
        // Inverse of receiveDataContainer.shopReceiveMethodChosen
        //         is receiveDataContainer.setShopReceiveMethodChosen((boolean) callbackArg_0)
        boolean callbackArg_0 = radioReceiveInStore.isChecked();
        // localize variables for thread safety
        // receiveDataContainer.shopReceiveMethodChosen
        boolean shopReceiveMethodCho = false;
        // receiveDataContainer
        com.abastra.home_cook.catalogue.data.models.ReceiveDataContainer receiveDataContainer = mReceiveDataContaine;
        // receiveDataContainer != null
        boolean receiveDataContainer = false;



        receiveDataContainer = (receiveDataContainer) != (null);
        if (receiveDataContainer) {




            receiveDataContainer.setShopReceiveMethodChosen((boolean) (callbackArg_0));
        }
    }
};