开发者

Android getStringArray returns only lower case

I'm quite new at this and would really appreciate any help on this.

I'm using getStringArray() to retrieve an array with strings. Each string has the first letter upper case. But when the array is loaded into the java array, all letters are lower case.

The array from arrays.xml:

    <string-array name="playerformatnames">
        <item>Red</item开发者_JAVA百科>
        <item>Orange</item>
        <item>Yellow</item>        
        <item>Green</item>
        <item>Blue</item>
        <item>Violet</item>
    </string-array>

The code to load the array:

    String[] playerFormatNames = 
        context.getResources().getStringArray(R.array.playerformatnames);

This will result in array contents: "red", "orange", yellow", ... The upper case characters are gone.

So my questions are:

  • Is this normal behaviour?
  • Am I doing it wrong if i want to keep the upper case letters?
  • Is it a bug / misconfiguration of Eclipse?

Thank you!


I haven't noticed this issue before but it certainly seems like a concern, as nasty as what I am about to suggest sounds it may be necessary. You might want to try something like this to preserve all formatting.

<string-array name="playerformatnames">
  <item><![CDATA[Red]]></item>
  ...
</string-array>

Which is to say, wrap the content of each element in CDATA.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜