Android getStringArray 仅返回小写字母
我对此很陌生,非常感谢对此的任何帮助。
我正在使用 getStringArray() 来检索包含字符串的数组。每个字符串的第一个字母大写。但是当数组加载到java数组中时,所有字母都是小写的。
arrays.xml 中的数组:
<string-array name="playerformatnames">
<item>Red</item>
<item>Orange</item>
<item>Yellow</item>
<item>Green</item>
<item>Blue</item>
<item>Violet</item>
</string-array>
加载数组的代码:
String[] playerFormatNames =
context.getResources().getStringArray(R.array.playerformatnames);
这将导致数组内容:“red”、“orange”、yellow”,... 大写字符消失了。
所以我的问题是:
- 这是正常行为吗?
- 如果我想保留大写字母,我做错了吗?
- 这是 Eclipse 的错误/配置错误吗?
谢谢你!
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>
<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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我以前没有注意到这个问题,但它看起来确实是一个问题,尽管我要建议的听起来很糟糕,但它可能是必要的。您可能想尝试类似的方法来保留所有格式。
也就是说,将每个元素的内容包裹在
CDATA
中。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.
Which is to say, wrap the content of each element in
CDATA
.