我在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?
当前回答
为了避免错误,使用提取字符串:
<string name="travels_tours_pvt_ltd"><![CDATA[Travels & Tours (Pvt) Ltd.]]></string>
其他回答
即使你的问题已经回答了,我仍然想告诉更多这样的实体。 这些都是html实体,所以在android中你可以这样写:
如下所示:
& with &
> with >
< with <
" with ", “ or ”
' with ', ‘ or ’
} with }
这是我的一个问题,我的解决方法如下:使用>对于>,<对于<,&For &,"'" For ', " For \"\"
对于特殊字符,我通常使用Unicode定义,例如“&”,如果我是正确的:\u0026。这里有一个很好的参考页面:http://jrgraphix.net/research/unicode_blocks.php?block=0
这可能很古老了。但对于那些寻找快速代码的人。
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;
}
它处理转义字符,您可以在它们各自的数组中添加字符和符号。
干杯
你可以这样写
<string name="you_me">You & Me<string>
输出:你和我