【发布时间】:2020-08-08 12:04:02
【问题描述】:
有两个自定义属性。
<declare-styleable name="CustomImageView">
<attr name="customTitle" format="reference" />
<attr name="customDrawableImage" format="reference" />
</declare-styleable>
<import type="java.util.List"/>
<variable
name="models"
type="List<com.full.path.package.model.Model>" />
<com.full.path.packages.test.CustomImageView
android:id="@+id/choice_quality_awful_image_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:customTitle="@{models.get(0).title}"/>
attrs 或逻辑数据绑定没有错误,因为我可以在app:customTitle 中设置另一个字符串,它会起作用。如果我在其他 textView 中设置 models.get(0).title 它将起作用。
但运行后出现以下错误(Android Studio 认为 customTitle 是 Bidning 适配器的命名并试图找到它)
Cannot find a setter for <com.lucid.dreaming.ui.choicequality.views.QualityImageView app:qualityTitle> 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.
如何标记它不是绑定适配器?
【问题讨论】:
标签: android kotlin data-binding android-custom-view