不能解析的Android资源字符串 [英] Can't Resolve Android Resource Strings
问题描述
我学习Android和我有什么,我认为这是一个奇怪的问题。
I am learning Android, and I have what I think is a weird problem.
在/res/values/strings.xml我有:
in /res/values/strings.xml I have:
<string name="titleStatus">Status Update</string>
在/res/layout/activity_status.xml我有:
in /res/layout/activity_status.xml I have:
<!-- Title TextView-->
<TextView android:layout_width="match_parent"
android:layout_height="wrap_content" android:gravity="center"
android:textSize="30sp"
android:layout_margin="10dp" android:text="@string/titleStatus"/>
但是,查看activity_status.xml当我收到错误:
However, when viewing activity_status.xml I am getting error:
错误:没有资源发现,给定的名称相匹配(在文与
值'@字符串/ titleStatus')。 activity_status.xml
Error: No resource found that matches the given name (at 'text' with value '@string/titleStatus'). activity_status.xml
我后来想通它可能有助于使用工程|清洁,但我得到了同样的问题(现在没有自动生成R.java类)
I then figured it could possibly help use "Project | Clean", but I get the same problem (and now without the auto-generated R.java class)
我下面这个教程/本书:
http://ofps.oreilly.com/titles/9781449390501/Android_User_Interface.html
I am following this tutorial/book: http://ofps.oreilly.com/titles/9781449390501/Android_User_Interface.html
推荐答案
当你添加一些资源文件,并尝试使用它在另一个而不先保存它,你会得到一个错误。
Whenever you add something to a resource file and try to use it in another without saving it first, you will get an error.
正常 CTRL + S
只是保存你的文件,因此不会在其他文件中的变化将发生编译。
The normal ctrl+s
just saves the file you're in, so compilation will occur without the changes in the other file.
pressing CTRL-Shift-S键
保存所有打开的文件的更改(同去文件 - &GT;保存所有
)。
Pressing ctrl-shift-s
saves changes in all open files (same as going to File -> Save All
).
就个人而言,我打 CTRL-Shift-O组合
, CTRL-Shift-F组合
和 CTRL-Shift-S键
每次我需要保存一些变化组织进口,格式化code修复缩进等,并保存所有更改。
Personally, I hit ctrl-shift-o
, ctrl-shift-f
and ctrl-shift-s
everytime I need to save some changes to organize the imports, format the code to fix indenting etc. and to save all changes.
这篇关于不能解析的Android资源字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!