我在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="you_me">You &#38; Me<string>

输出:你和我

其他回答

应该是这样的:

<string name="game_settings_dragNDropMove_checkBox">Move by Drag&amp;Drop</string>

&在字符串中:

<string name="string_abc">Translate &amp; Scan Objects</string>

输出将是:

翻译和扫描对象

即使你的问题已经回答了,我仍然想告诉更多这样的实体。 这些都是html实体,所以在android中你可以这样写:

如下所示:

& with &amp;
> with &gt;
< with &lt;
" with &quot;, &ldquo; or &rdquo;
' with &apos;, &lsquo; or &rsquo;
} with &#125;

你可以这样写

<string name="you_me">You &#38; Me<string>

输出:你和我