我使用数据绑定来设置我的ImageView
的色调。这很有效:
android:tint="@{plantEntity.isFavorite ? @color/favorite : @color/favorite_none}" />
问题在于android:tint
已被弃用。当我试图使用app:tint
替代时,就出现了这个错误:
Cannot find a setter for <android.widget.ImageView app:color> that accepts parameter type 'int'
If a binding adapter provides the setter, check that the adapter is annotated correctly and that the parameter type matches.
为什么我需要创建一个 BindingAdapter
?我需要做什么?
app:
前缀。 - ubuntudroid