有两个自定义属性。
<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}"/>
属性或逻辑数据绑定中没有错误,因为我可以在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.
如何标记它不是绑定适配器?
使用
app:customTitle="@={model.title}"
insted of
app:customTitle="@{model.title}"