Как задать информацию в xml из модели привязки данных в атрибутах пользовательского представления - PullRequest
1 голос
/ 24 апреля 2020

Есть два пользовательских атрибута.

<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&lt;com.full.path.package.model.Model&gt;" />

<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}"/>

Нет ошибок в атрибутах или логах c Привязка данных, потому что я могу установить другую строку в app:customTitle, и это будет работать. И если я установлю models.get(0).title в другом textView, это будет работать. Но после запуска у меня появляется следующая ошибка (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.

Как пометить, что это не Binding Adapter?

1 Ответ

0 голосов
/ 24 апреля 2020

использование

app:customTitle="@={model.title}"

insted из

app:customTitle="@{model.title}"
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...