android - Algolia 的 xml 的“属性”引发编译错误
问题描述
我正在尝试使用他们的结果 UI 并遵循他们的指南来实现 Algolia。
我已将我的应用程序的 build.gradle 放入dataBinding.enabled true
如下
android {
compileSdkVersion 28
buildToolsVersion "29.0.0"
dataBinding.enabled true
......
在我的单次点击布局中,我只有一个 TextView,我尝试按照以下说明对其进行 binf,但它会引发编译错误:
<?xml version="1.0" encoding="utf-8"?>
<layout
xmlns:algolia="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android">
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/algolia_question_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
tools:text="Not able to succefully rum npm install comand on git bash"
android:fontFamily="@font/roboto_medium"
android:textSize="15sp"
android:textColor="@color/gray900"
algolia:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="24dp"
algolia:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp"
algolia:layout_constraintEnd_toEndOf="parent"
android:layout_marginEnd="24dp"
algolia:attribute='@{"title"}'/>
<View
android:id="@+id/divider4"
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="?android:attr/listDivider"
algolia:layout_constraintTop_toBottomOf="@+id/algolia_question_title"
android:layout_marginTop="8dp"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
如果我删除这一行algolia:attribute='@{"title"}'
,它编译就好了。我哪里错了?
编辑:我能够找到一条错误消息,内容如下:
Cannot find the setter for attribute 'algolia:attribute' with parameter type java.lang.String on android.widget.TextView.file:C\
该消息可能还有更多内容,但仅当我将鼠标悬停在某个错误行上并一直持续到屏幕末尾时才会出现,因此由于我不熟悉此消息,因此我无法判断是否还有更多内容。
解决方案
添加此实现后添加了我的问题
implementation 'com.algolia:instantsearch-androidx:1.15.2'
推荐阅读
- javascript - 使用单个输入字段上传多个图像,每个图像使用 JS/JQuery 有自己的输入字段
- python - OpenGL.error.NullFunctionError:尝试调用未定义函数glutInit,调用前检查bool(glutInit)
- python - 为什么 colab 会断开连接?
- python - 输出不显示我从 myphpadmin 搜索的结果
- oracle - Oracle 更改连接标识符
- html - 我在primeng中收到多个确认对话框
- php - PHPUNIT 回调方法更改外部变量
- javascript - 未处理的拒绝 (TypeError):conversations.map 不是函数
- amazon-web-services - AWS DMS 迁移挑战
- ssh - vscode 连接到 ssh 机器内部的 ssh 机器