У меня проблема с BindingAdapter
при использовании атрибута типа Enum
. Когда я использую Int, проблема не возникает.
Мой BindingAdapter
@BindingAdapter("app:setImage")
fun ImageView.setImage(transactionType: TransactionType) {
when (transactionType) {
TransactionType.EXPENSE -> this.setImageResource(R.drawable.ic_transaction_expense)
TransactionType.REVENUE -> this.setImageResource(R.drawable.ic_transaction_revenue)
}
}
My Enum
enum class TransactionType {
REVENUE,
EXPENSE
}
Мой объект
class Transaction(
val description: String,
val date: Date,
val value: Double,
val transactionType: TransactionType
)
Мой макет
...
<data>
<variable name="transaction" type="com.paulobressan.financas.model.Transaction"/>
</data>
...
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:srcCompat="@drawable/ic_transaction_expense"
android:id="@id/image_item"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintTop_toTopOf="parent"
android:padding="8dp"
tools:ignore="ContentDescription"
app:setImage="@{transaction.transactionType}"
/>
e: [kapt] An exception occurred: android.databinding.tool.util.LoggedErrorException: Found data binding errors.
****/ data binding error ****msg:Could not find accessor com.paulobressan.financas.model.Transaction.transactionType file:/home/paulo/data/projects/Financas2/app/src/main/res/layout/item_transaction.xml loc:35:36 - 35:62 ****\ data binding error ****