使用数据绑定处理 HTML 个实体
Handle HTML entity with Data Binding
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="android.text.Html"/>
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:text="@{Html.fromHtml(`some message from model` + ` `)}"/>
</RelativeLayout>
</layout>
在这里,我试图在 TextView
中的文本后留下一些空白 space,但它显示 此错误。
Error:Execution failed for task ':app:dataBindingProcessLayoutsDebug'.
The entity "nbsp" was referenced, but not declared.
我已经尝试在 xml 中使用简单的 space,但它不会留空 spaces android:text="@{'some message from model' + ' '}"
删除 @nbsp
并尝试使用它 hexa(decimal)
值  
。
因为在XML中主要的五个实体如下:
quet(")
、amp(&)
、apos(')
、It(<)
和 gt(>)
其中 @nbsp
不存在,因此您需要使用它是十六进制(十进制)值  
.
如果我们必须使用 HTMl 将 Space 放在 XML 中,我们使用  
但是在 Xml 中它给出了这个错误:
The entity "nbsp" was referenced, but not declared.
因为 XMl 的主要五个实体是我定义的 Upper 所以你必须使用它的十六进制(十进制)值..
所以  
你必须  
。但同样 &
是 XMl 实体,所以你必须将 &
转换为 &
这样它就可以工作了。
简而言之:
 
表示&#160
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<import type="android.text.Html"/>
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:text="@{Html.fromHtml(`some message from model` + ` `)}"/>
</RelativeLayout>
</layout>
在这里,我试图在 TextView
中的文本后留下一些空白 space,但它显示 此错误。
Error:Execution failed for task ':app:dataBindingProcessLayoutsDebug'.
The entity "nbsp" was referenced, but not declared.
我已经尝试在 xml 中使用简单的 space,但它不会留空 spaces android:text="@{'some message from model' + ' '}"
删除 @nbsp
并尝试使用它 hexa(decimal)
值  
。
因为在XML中主要的五个实体如下:
quet(")
、amp(&)
、apos(')
、It(<)
和 gt(>)
其中 @nbsp
不存在,因此您需要使用它是十六进制(十进制)值  
.
如果我们必须使用 HTMl 将 Space 放在 XML 中,我们使用  
但是在 Xml 中它给出了这个错误:
The entity "nbsp" was referenced, but not declared.
因为 XMl 的主要五个实体是我定义的 Upper 所以你必须使用它的十六进制(十进制)值..
所以  
你必须  
。但同样 &
是 XMl 实体,所以你必须将 &
转换为 &
这样它就可以工作了。
简而言之:
 
表示&#160