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

Hello can you please help me with this task 2 of 5 in Java

In StringTest.java add a String variable named 'label' before the call to setText(). Use the getString(int id) method to set 'label' to the value you just added in strings.xml. The id will begin with 'R.string'.

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

Button saveButton = (Button) findViewById(R.id.saveButton);

String label = getString(R.String.saveLabel);

saveButton.setText("SAVE");

2 Answers

Andres Mendoza
Andres Mendoza
3,088 Points

you are probably getting a syntax error, you need to double check your code:

String label = getString(R.string.saveLabel);

you were almost there but you had 'R.String' when it should be 'R.string'

Haha! You are right I was getting a syntax error. I had a long day yesterday I was doing so well with my learning and then suddenly I was stuck.. Thank you very much!!

Andres Mendoza
Andres Mendoza
3,088 Points

You're Welcome, can you mark this complete?