Html.fromHtml in DataBinding - Android
android, android-databinding
Solution
Think you need to import html first in the xml
<data>
<import type="android.text.Html"/>
</data>
<TextView
android:id="@+id/txtDateCreate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{Html.fromHtml(String.format(@string/DateCreate,others.created))}" />
Problem
I am using from `dataBinding` in my project,when I have bellow `xml` it good work : ``` <TextView android:id="@+id/txtDateCreate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@{String.format(@string/DateCreate,others.created)}" /> ``` But when I change to bellow get me crash: ``` <TextView android:id="@+id/txtDateCreate" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@{Html.fromHtml(String.format(@string/DateCreate,others.created))}" /> ``` Here in my `string.xml` : ``` <resources> <string name="DateCreate">open : <![CDATA[<b><font color=#FF0000>%s</b>]]></string> </resources> ```