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

Seyfullah Erdogan
Seyfullah Erdogan
1,922 Points

How do you do this question: In StringTest.java add a String variable named 'label' before the call to setText().

please Help

2 Answers

Chris Shaw
Chris Shaw
26,676 Points

Hi ,

I'm not an Android developer but after reading the documentation for getString it made perfect sense how to complete the challenge.

http://developer.android.com/guide/topics/resources/string-resource.html#String

The answer is in the question if would have realised.
There are two files open in the challenge strings.xml and StringTest.java

In general this is how the declaration is done which I'm sure you must be a pro by now assuming that you have reached this far. DataType variable_name;

So as per your question your Datatype is String and variable_name is lable

In addition you need to set it just before the line saveButton.setText("SAVE");

Of what I can see in the challenge there is more to this question. I am never in favour of giving away answers, however I would advice to give it a try yourself before you look at the solution below.
Hope this helps

Solution

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

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

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

saveButton.setText("SAVE");