40

ファイルに次の文字列配列を作成したいと思いstrings.xmlます。

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

ここでの文字列は「%selectpercentage」です。これを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

そのコードを使用できます。これを試して:&#37;

同様の質問も確認してください:AndroidXMLパーセント記号

于 2012-10-22T12:35:48.067 に答える