【发布时间】:2013-05-24 15:19:25
【问题描述】:
这里是一个 Android 菜鸟。
所以,我正在关注 Lars Vogel 的 this 指南(第 20 节)。我在谷歌修改后的Eclipse中启动了一个新的Android Application Project,并编辑了strings.xml,所以看起来是这样的:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Temperature Converter</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<color name="myColor">#F5F5F5</color>
<string name="celsius">to Celsius</string>
<string name="fahernheit">to Fahrenheut</string>
<string name="calc">Calculate</string>
</resources>
(前3个字符串是默认的)
然后我使用图形布局将TextView 添加到activity_main.xml。我尝试使用图形布局更改TextView 的文本属性。对于一些我添加的新字符串没有显示在资源选择器中。
我只能在 3 个默认字符串之间进行选择。但字符串。
为什么?
(我也尝试过使用文本 xml 编辑器。它不起作用。)
谢谢!
【问题讨论】:
-
移除颜色元素,清理并重建您的项目。如果你想要颜色元素,你必须在 values 中创建一个名为 colors 的文件
-
@blackbelt
color不是问题。颜色和字符串都是值资源,可以在 res/values 目录下的任何 .xml 文件中。
标签: java android xml eclipse string