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

challenge task 5 - syntax error

someone help! this is my last part of answer in Java file.

Resources resources = getResources();
MphoneNumberLabels = resources.getStringArray(R.array.phoneNumberLabels);

"phoneNumberLabels" is same as string-array variable in XML file. I keep getting errors telling me that symbol cant find or match... what am I missing?

2 Answers

Ben Jakuben
STAFF
Ben Jakuben
Treehouse Teacher

Looks like you're using the wrong variable name: MphoneNumberLabels

Thank you for your help. I changed the variable and this is my entire code in Java. Also, I addd a new array-list named phoneNumberLabels in XML file.

String[] phoneNumberLabels;

Button saveButton = (Button) findViewById(R.id.saveButton);
String label = getString(R.string.saveLabel);
saveButton.setText(label);
Resources res = getResources();
phoneNumberLabels = res.getStringArray(R.array.phoneNumberLabels);

I'm still getting the same error message that symbol (R.array.phoneNumberLabels) cant find on the last line. I'm stuck on this problem. Any advise please.

Ben Jakuben
Ben Jakuben
Treehouse Teacher

In your last line, check the name you are using for the array from the strings.xml file. :)

Figured it out! I didn't need to change the name at all... How simple it was! Thanks a lot.