Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am using the Android Data Binding library. I have a requirement that if the bound number is less than 10, I need to show it with a zero appended (like 01, 05), and else show the normal number.

Here's 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 build 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 issue?

like image 430
Sasank Sunkavalli Avatar asked Dec 05 '16 09:12

Sasank Sunkavalli


1 Answers

Use &lt; instead of <

Use &gt; instead of >

Use &amp; instead of &

like image 166
Tom Sabel Avatar answered Nov 14 '22 16:11

Tom Sabel