Android data binding, the value of the "android: text" attribute associated with the type of the "TextView" element must not contain the character "<"

I am using Android data binding library . I have a requirement that if the linked number is less than 10, I need to show it with an added zero (e.g. 01 , 05 ), and also show a normal number.

Here is the relevant part of my layout:

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

But when I create the project, it throws the following error: The value of attribute "android:text" associated with an element type "TextView" must not contain the '<' character

How can I solve this problem?

+5
source share
1 answer

Use &lt; instead of <

Use &gt; instead of >

Use &amp; instead of &

+13
source

Source: https://habr.com/ru/post/1260804/


All Articles