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
Adnan Hasbi
4,544 PointsBlogReader App
Hi,
My Question:
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'.
My answer:
String[] phoneNumberLabels = { "-home", "-work", "-mobile" };
Button saveButton = (Button) findViewById(R.id.saveButton);
String.label(this, getString(R.string.label), setText();
saveButton.setText("SAVE");
Please help.
7 Answers
Paul Kim
1,025 PointsThanks Ben solved it although it good to remember the word "set" means to put the equal sign i keep forgetting
Andre' Jones
26,671 Pointslabel is not a method for string so no dot in between String and label.
I think the answer is String label(this, getString(R.string.label)
then change the "SAVE" inside the setText() to label no quotes.
Ben Jakuben
Treehouse TeacherAs Andre' said, you don't want the dot between String and label. So first, you need to declare a variable named label of type String:
String label
Then you need to set it using the getString(int id) method just like in the video. Start watching around 5:45 for an example that should help you: http://teamtreehouse.com/library/build-a-blog-reader-android-app/rebuilding-from-scratch/all-about-string-resources-2
Adnan Hasbi
4,544 PointsHi,
Thanks guys Sorry for ultra late reply, I was creating some Christmas apps... BTW Ben, I took the lessons you thought me on the first app and create a couple of apps for Christmas :) The apps in these links :
https://play.google.com/store/apps/details?id=com.adhastudio.paytimer&hl=en https://play.google.com/store/apps/details?id=com.adhastudio.scanner&hl=en
Thank You so much for the android lessons. Now I need to learn how to market them ... so far I think I am the only one that has downloaded these apps :)
Ben Jakuben
Treehouse TeacherHow fun! Add two more downloads to your totals. :) Great work!
Adnan Hasbi
4,544 PointsThanks ...
I will now resume the lessons on creating a blog reader and try to answer the questions
Thanks again for the support.
PS I am up to 150 downloads for the naughty nice app:)
Paul Kim
1,025 PointsI am also stuck I don't know what to do this is all I got so far. string label(this, getString(R.string.label);
Ben Jakuben
Treehouse TeacherHi Paul! Check out my comment above. You need to start with String label (make sure you have a capital "S"). Then you need to set it (with the equals sign) and on the right side of the equals sign, use the getString(int id) method just like in the video.
Rajesh Mule
2,125 PointsString label = getString(R.string.saveLabel);
Ben Jakuben
Treehouse TeacherBen Jakuben
Treehouse TeacherExcellent! Glad you got it without a direct answer. :)