android - 将属性从包含的布局传递给布局时出错
问题描述
为了使我的应用程序代码更清晰,我尝试创建通用 xml,但出现如下错误:
error: activity_login.xml:230: AAPT: error: attribute buttonTitle
在我的 Login.xml 文件中:
<include
android:id="@+id/login_button"
layout="@layout/widget_large_button"
app:buttonTitle="@string/login"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"/>
我已经定义了如下布局:
<data>
<variable
name="buttonTitle"
type="String"/>
</data>
<androidx.appcompat.widget.AppCompatButton
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="25dp"
android:layout_marginEnd="25dp"
android:layout_marginBottom="16dp"
android:background="@drawable/stripe_backgound_05"
android:clickable="false"
android:focusable="false"
android:letterSpacing="0.5"
android:paddingTop="25dp"
android:paddingBottom="25dp"
android:text="@{buttonTitle}"
android:textAllCaps="true"
android:textColor="@color/gainsboro_05"
android:textSize="16sp"/>
看来我无法将 login.xml 中的 buttonTitle 传递给按钮小部件。
任何想法?
谢谢
解决方案
尝试添加bind:buttonTitle="@{'variable name of login.xml'}"
包含标签
推荐阅读
- arrays - 显示数组中仅包含特定属性的对象
- c# - 在文本框中的每个字符之间插入某个字符
- javascript - date() 方法如何获得我们时区的准确时间?
- python - 如何在 matplotlib 中创建非线性颜色条刻度
- javascript - Adobe InDesign Javascript 错误!错误号:55 错误字符串:对象不支持属性或方法“documentPreferences”
- php - 仅当表单通过错误检查时,如何转到表单提交的新页面?
- r - 基于闪亮仪表板中的多个 DT 行选择存储和打印单元格值
- python - 时间和空间复杂度比较:通过循环或dict(zip(s, t))将两个列表的元素添加到一个dict
- python - 翻转字典无法正常工作python
- reactjs - 如何防止电子反应应用程序的“导航到 http://localhost:3000/”