Can't resolve android resource strings
I am learning Android and I have what I find to be a strange problem.
in / res / values / strings.xml I have:
<string name="titleStatus">Status Update</string>
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"/>
However, when viewing activity_status.xml, an error occurs:
Error: The resource could not be found that matches the specified name (in 'text' with value '@ string / titleStatus'). activity_status.xml
Then I realized that it might help to use "Project | Clean", but I get the same problem (and now without the auto-generated R.java class)
I am following this tutorial / book: http://ofps.oreilly.com/titles/9781449390501/Android_User_Interface.html
source to share
Whenever you add something to a resource file and try to use it in another without saving it first, you will get an error.
Normal ctrl+s
just saves the file you are in, so compilation will happen unchanged in the other file.
Clicking ctrl-shift-s
saves the changes in all open files (the same as in File -> Save All
).
Personally, I hit ctrl-shift-o
, ctrl-shift-f
and ctrl-shift-s
every time I had to keep some change for the organization of import, format the code to correct the indentation etc. and save all changes.
source to share