Android 双向数据绑定错误:无法解析布尔属性的setter

Android 双向数据绑定错误:无法解析布尔属性的setter,android,data-binding,Android,Data Binding,我尝试在复选框上使用双向数据绑定: <layout xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools"> <data> <import type="android.view.View"/> <variable name="viewModel

我尝试在复选框上使用双向数据绑定:

<layout xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools">
    <data>
        <import type="android.view.View"/>
        <variable
            name="viewModel"
      type="com.epsilon.startbodyweight.selectorActivity.SelectorViewModel"/>
        <variable
            name="index"
            type="int" />
    </data>

    <android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <CheckBox
            android:id="@+id/cb_active_exer"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="8dp"
            android:checked="@={viewModel.exerciseList[index].isActive}" />

这是指Android Studio 2.2中的一个bug,它使用的是Java。我正在使用Kotlin的3.2版


我试图手动为函数isActive创建一个setter,但它抱怨已经为布尔属性定义了一个setter。

在编写绑定表达式时,将@JvmField注释添加到ExerciseEntity类的isActive属性中。Kotlin
Boolean
s以
is开头
在绑定表达式语言中显示,但不显示它

例如,考虑一个KTLIN数据类,它的属性叫<代码> ISActudio./P>

数据类练习(变量isActive:Boolean)
在绑定表达式中,此属性将显示为
active
,而不是
isActive



分享你的课程SelectorViewModel@KrishnaSharma补充!除了viewModelExerciseListIndex,一切看起来都很好。@KrishnaSharma那么为什么你认为我会出现这个错误?你找到原因了吗??如果不在github中共享代码库,我也可以进行调试
@Entity
class ExerciseEntity {
    var exerciseName: String = ""
    @PrimaryKey
    var exerciseNum: Int = 0
    var progressionName: String = ""
    var progressionNumber: Int = 0
    var set1Reps: Int = 0
    var set2Reps: Int = 0
    var set3Reps: Int = 0
    var setTime: Int = 0
    var isTimedExercise: Boolean = false
    var numAttempts: Int = 0
    var isActive: Boolean = true

    // Do not store the following items in our DB
    @Ignore var allProgressions: ArrayList<String> = ArrayList()
    @Ignore var nextSet1Reps: Int = 0
    @Ignore var nextSet2Reps: Int = 0
    @Ignore var nextSet3Reps: Int = 0
    @Ignore var nextSetTime: Int = 0
    @Ignore var nextNumAttempts: Int = 0
    @Ignore var nextProgressionName: String = ""
    @Ignore var nextProgressionNumber: Int = 0
    @Ignore var isModified: Boolean = false
    @Ignore var exerMessage: String = ""
    @Ignore var isSet1Complete: Boolean = false
    @Ignore var isSet2Complete: Boolean = false
    @Ignore var isSet3Complete: Boolean = false
    @Ignore var isSetTimeComplete: Boolean = false
}
class SelectorViewModel : ViewModel() {
    private val mExerciseList = MutableLiveData<ArrayList<ExerciseEntity>>()
    val exerciseList : LiveData<ArrayList<ExerciseEntity>>
        get() = mExerciseList

    init {
        mExerciseList.value = ArrayList()
    }

    fun populateExerciseListFromDB(myDBExercises: List<ExerciseEntity>) {
        // .... Load our exer list from DB ... //


        mExerciseList.value?.addAll(myDBExercises)
        // Use the "setValue" method to notify observers of change
        mExerciseList.value = mExerciseList.value
    }

    private fun updateRepsInExercise(exercise: ExerciseEntity, reps1: Int, reps2: Int, reps3: Int) {
        exercise.set1Reps = reps1
        exercise.set2Reps = reps2
        exercise.set3Reps = reps3

        mExerciseList.value = mExerciseList.value
    }

    fun incrementSet(exercise: ExerciseEntity, smallIncrement: Boolean) {
            // ... Compute the new reps ... //
            updateRepsInExercise(exercise, numReps1, numReps2, numReps3)
    }
}