Android字符串数组显示百分号

Android字符串数组显示百分号,android,arrays,xml,Android,Arrays,Xml,我在strings.xml文件中有一个字符串数组,其中包含多个项。只有一个项目具有多个需要显示的百分比“%”符号。似乎所有关于如何逃避的建议都不管用。\%,%%或者在字符串数组或items标记上使用formatted=“false”。当我使用\%Eclipses显示项目错误时,如果我使用%%,则Eclipse正常运行,但文本显示两个百分号“%%”。那么,关于如何在strings.xml中转义%sign有什么想法吗 <string-array name="details">

我在strings.xml文件中有一个字符串数组,其中包含多个项。只有一个项目具有多个需要显示的百分比“%”符号。似乎所有关于如何逃避的建议都不管用。\%,%%或者在字符串数组或items标记上使用formatted=“false”。当我使用\%Eclipses显示项目错误时,如果我使用%%,则Eclipse正常运行,但文本显示两个百分号“%%”。那么,关于如何在strings.xml中转义%sign有什么想法吗

<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>

事物的位置
放置时间的百分比为30%
发布次数占50%

您的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>

事物的位置

显然,使用旧版本的eclipse而没有最新的android SDK会产生这个问题。我将eclipse升级到3.6.2,并确保安装了最新版本的android sdk r10。所以希望这能帮助别人,节省他们的时间,因为我浪费了几个小时试图修复/找到答案


因此,这个问题的答案是,您可以在一个字符串数组项中多次使用一个%符号,而无需转义它、加倍或使用CDATA,只要您拥有最新版本的SDK和Eclipse。

我也有同样的问题,但没有什么要做的,在JB 4.1.2上对我没有任何作用。
以下是我尝试过的:

<string-array name="percentage">
    <item>a. 100%</item>            <!-- unknownFormatConversionException -->
    <item>b. 90&#37;</item>         <!-- unknownFormatConversionException -->
    <item>c. 80%%</item>            <!-- "somewhere" a double %% appears -->
    <item>d. 60\%</item>            <!-- no % appears -->
    <item>e. 40\%%</item>           <!-- unknownFormatConversionException -->
    <item>f. 30%\%</item>           <!-- unknownFormatConversionException -->
    <item><![CDATA[g. 20%]]></item> <!-- unknownFormatConversionException -->
    <item formatter="false>h. 10%</item>    <!-- unknownFormatConversionException -->
</string-array>

A.100%            
B90%         
C80%%            
D60\%            
E40\%%           
F30%\%           

一个棘手的方法是使用百分号的unicode字符

U+FE6A ﹪ small percent sign (HTML &#65130; )
U+FF05 % full-width percent sign (HTML &#65285;)
在XML中,您可以定义如下

    <string-array name="details">
         <item>Placement of things</item>
         <item>Percentage of times placed is 30&#65130; 
             and percentage of times release 50&#65130;</item>
    </string-array>

事物的位置
放置时间的百分比为30﹪;
发布次数占50﹪次;

对我有效的方法是在strings.xml中声明一个新字符串,并使用百分比符号和属性formatted=“false”


10%;不是20岁%岁;显然,字符串数组中同一字符串项中的多个百分比转义中存在错误。我可以使用%;一次,如果我在同一个项目中使用了多次,它就会出错。奇怪的是,我可以完美地添加“%”,这没有问题。你能解释一下你的代码到底是做什么的吗?没有什么可以解释的,我想逐字显示这两个字符串。Eclipse给了我错误,我无法编译。嗯,我有错误,我很确定我有最新的更新。看起来很奇怪,我尝试了CDATA方法,但在Eclipse中也出现了错误。有趣的答案是,尽管correct的评级为负值……不确定为什么会有人不同意,因为这是解决方案。哇,这仍然是最近安卓版本的一个问题?嗯,这是三星,他们的做法不同。
    <string-array name="details">
         <item>Placement of things</item>
         <item>Percentage of times placed is 30&#65130; 
             and percentage of times release 50&#65130;</item>
    </string-array>
<string name="percents" formatted="false">10&#37; is not 20&#37;</string
<string-array name="my_array">
    <item>@string/percents</item>
    ...