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

Christian Bonanno
Christian Bonanno
1,063 Points

Blog Reader Android App

HI,

I am trying to work out a quiz in the Blog Reader Android App tutorial. I have the following 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'."

I have added the following line in the strings.xml file: "<string name="saveLabel">Save My Changes</string>"

I have also added these lines of code in the StringTest.java: "Resources resources = getResources(); String label = resources.getStringArray(R.string.label);"

I can't figure out what I am doing wrong.

I can't see the first line of code you are referring to. Can you mark it down by adding 3 backticks and "java" in the line before the code and 3 backticks in the line after the code as the cheatsheet says "Wrap your code with 3 backticks (```) on the line before and after. If you specify the language after the first set of backticks, that'll help us with syntax highlighting."

1 Answer

Christian Bonanno
Christian Bonanno
1,063 Points

Hi Gloria. Thanks for your help, however I have managed to do the challenge. What I was doing wrong was that I was referring to the variable label whereas I should have referred to the variable saveLabel.

Oh okay. I couldn't see the full code so it was pretty hard to see the error. I am glad you figured it out :)