Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Blog Reader Android App Rebuilding from Scratch All About @string Resources

Wei-Ting Chen
Wei-Ting Chen
7,632 Points

What does 'R' mean in the R.string?

what does 'R' mean? We have seen it so often,but I can't remember what it means. Thanks a lot!

StringTest.java
String[] phoneNumberLabels = { "-home", "-work", "-mobile" };

Button saveButton = (Button) findViewById(R.id.saveButton);
String label=getString(R.String);

saveButton.setText("SAVE");
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
  <string name="saveLabel">Save My Changes</string>

   <!-- <string-array name="saveLabel">
    <item>Save My Changes</item>
    <item>work</item>
    <item>mobile</item>
   </string-array>-->

</resources>

2 Answers

Once you provide a resource in your application (discussed in Providing Resources), you can apply it by referencing its resource ID. All resource IDs are defined in your project's R class, which the aapt tool automatically generates.

http://developer.android.com/guide/topics/resources/accessing-resources.html