数据绑定中的Html.fromHtml-Android [英] Html.fromHtml in DataBinding - Android
本文介绍了数据绑定中的Html.fromHtml-Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在项目中使用dataBinding
时,当我具有xml
波纹管时效果很好:
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))}" />
在我的string.xml
中:
<resources>
<string name="DateCreate">open : <![CDATA[<b><font color=#FF0000>%s</b>]]></string>
</resources>
推荐答案
认为您首先需要在xml中导入html
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))}" />
这篇关于数据绑定中的Html.fromHtml-Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文