我在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 CDATA,就像Android Studio为你做的,当你提取字符串资源
<弦name = " game_settings_dragNDropMove_checkBox > < ![CDATA[trag&drop Move]></字符集
其他回答
应该是这样的:
<string name="game_settings_dragNDropMove_checkBox">Move by Drag&Drop</string>
这可能很古老了。但对于那些寻找快速代码的人。
public String handleEscapeCharacter( String str ) {
String[] escapeCharacters = { ">", "<", "&", """, "'" };
String[] onReadableCharacter = {">", "<", "&", "\"\"", "'"};
for (int i = 0; i < escapeCharacters.length; i++) {
str = str.replace(escapeCharacters[i], onReadableCharacter[i]);
} return str;
}
它处理转义字符,您可以在它们各自的数组中添加字符和符号。
干杯
Mac和Android工作室用户:
在string.xml或布局中键入你的字符,如&,并选择“选项”和“返回”键。 请参考截图
这是我的一个问题,我的解决方法如下:使用>对于>,<对于<,&For &,"'" For ', " For \"\"
编码:
&