我的 strings.xml 文件中有一个字符串数组,其中包含多个项目。只有一个项目有多个百分比“%”符号需要显示。似乎没有关于如何逃避它的建议。\%, %% 或在字符串数组或项目标签上使用 formatted="false"。当我使用\% Eclipses 显示项目错误时,如果我使用 %% 那么 Eclipse 可以正常运行,但随后文本显示两个百分号“%%”。那么关于如何在 strings.xml 中转义 % 有什么想法吗?
<string-array name="details">
<item>Placement of things</item>
<item>Percentage of times placed is 30%
and percentage of times release 50%</item>
</string-array>
最佳答案
您的 ADT 插件和 SDK 更新了吗? 我的已更新,未显示此错误。只需 1% 就可以发挥魅力。
无论如何,您是否尝试过将字符串放入 CDATA 中?
<string-array name="details">
<item>Placement of things</item>
<item><![CDATA[Percentage of times placed is 30%
and percentage of times release 50%]]></item>
</string-array>
关于Android 字符串数组显示百分号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5465351/