Android 数据绑定,与元素类型 "TextView" 关联的属性 "android:text" 的值不得包含“<”字符
Android Data binding, The value of attribute "android:text" associated with an element type "TextView" must not contain the '<' character
我正在使用 Android 数据绑定库。我有一个要求,如果绑定数字小于 10,我需要在显示它时附加一个零(如 01
、05
),否则显示正常数字。
这是我布局的相关部分:
<TextView
android:id="@+id/tlm_no"
style="@style/BlackSmallTextStyle"
android:layout_width="@dimen/study_plan_icon_width"
android:layout_height="wrap_content"
android:layout_below="@id/tlm_image"
android:gravity="center"
android:fontFamily="sans-serif-light"
android:text="@{studyPlanDetailVM.studyPlanDetail.learningPlanResource[0] < 10 ? `0` + studyPlanDetailVM.studyPlanDetail.learningPlanResource[0] : studyPlanDetailVM.studyPlanDetail.learningPlanResource[0]}" />
但是当我构建项目时它抛出以下错误:
The value of attribute “android:text” associated with an element type “TextView” must not contain the '<' character
我该如何解决这个问题?
使用<
代替<
使用>
代替>
使用&
代替&
我正在使用 Android 数据绑定库。我有一个要求,如果绑定数字小于 10,我需要在显示它时附加一个零(如 01
、05
),否则显示正常数字。
这是我布局的相关部分:
<TextView
android:id="@+id/tlm_no"
style="@style/BlackSmallTextStyle"
android:layout_width="@dimen/study_plan_icon_width"
android:layout_height="wrap_content"
android:layout_below="@id/tlm_image"
android:gravity="center"
android:fontFamily="sans-serif-light"
android:text="@{studyPlanDetailVM.studyPlanDetail.learningPlanResource[0] < 10 ? `0` + studyPlanDetailVM.studyPlanDetail.learningPlanResource[0] : studyPlanDetailVM.studyPlanDetail.learningPlanResource[0]}" />
但是当我构建项目时它抛出以下错误:
The value of attribute “android:text” associated with an element type “TextView” must not contain the '<' character
我该如何解决这个问题?
使用<
代替<
使用>
代替>
使用&
代替&