40

我想在我的strings.xml文件中创建以下字符串数组:

<string-array name="an_array_columns">
         <item>% Select percentage1</item>
         <item>% Select percentage2</item>
</string-array>

这里的字符串是“% 选择百分比”。现在,当我在我的 strings.xml 中写这个时,我收到以下错误:

Multiple annotations found at this line:
    - error: Multiple substitutions specified in non-positional format; did you mean to 
     add the formatted="false" attribute?
    - error: Found tag </item> where </string-array> is expected

我知道我们可以更改&&amp;'\'但是我该怎么做百分号?

4

2 回答 2

102

%%似乎对我有用。例如:

<string name="num_percent">%1$d %%</string>

String oneHundredPercentString = getString(R.string.num_percent, 100); // This gives "100 %"

于 2017-02-13T17:22:10.253 回答
52

You can use its code. Try this: &#37;

Also check the similar question: Android XML Percent Symbol

于 2012-10-22T12:35:48.067 回答