我在strings.xml文件中写了以下内容:
<string name="game_settings_dragNDropMove_checkBox">Move by Drag&Drop</string>
我得到了以下错误:
The reference to entity "Drop" must end with the ';' delimiter.
我怎么能写字符&在字符串。xml?
我在strings.xml文件中写了以下内容:
<string name="game_settings_dragNDropMove_checkBox">Move by Drag&Drop</string>
我得到了以下错误:
The reference to entity "Drop" must end with the ';' delimiter.
我怎么能写字符&在字符串。xml?
当前回答
如果您想直接在xml中硬编码字符串,可以通过这种方式将其相加。
<TextView
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="You & Me"
其他回答
这是我的一个问题,我的解决方法如下:使用>对于>,<对于<,&For &,"'" For ', " For \"\"
编码:
&
如果您想直接在xml中硬编码字符串,可以通过这种方式将其相加。
<TextView
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="You & Me"
为了避免错误,使用提取字符串:
<string name="travels_tours_pvt_ltd"><![CDATA[Travels & Tours (Pvt) Ltd.]]></string>
即使你的问题已经回答了,我仍然想告诉更多这样的实体。 这些都是html实体,所以在android中你可以这样写:
如下所示:
& with &
> with >
< with <
" with ", “ or ”
' with ', ‘ or ’
} with }