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 an Interactive Story App (Retired) Intents and Multiple Activities Using String Resources

Bart Kluczynski
Bart Kluczynski
15,326 Points

No idea how to use the buttonLabel

Hi guys,

Can you please help, as i am stuck and i could not find any relevant answer in the forum?

I am trying to set the text for loadPuppiesButton with buttonLabel variable, but i clearly do something wrong.

Finally, use the buttonLabel variable to set the text for loadPuppiesButton instead of the current hard-coded String.

Cheers!

CodeChallenge.java
Button loadPuppiesButton = (Button) findViewById(R.id.puppiesButton);
String buttonLabel = getString(R.string.morePuppies);
String buttonLabel = loadPuppiesButton.setText("LOAD");



           //     String name = mNameField.getText().toString();
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
  <string name="morePuppies">See More Puppies</string>
</resources>

5 Answers

Suleyman Orazgulyyev
PLUS
Suleyman Orazgulyyev
Courses Plus Student 5,798 Points

Hey, I know It's been a while, and you probably solved the problem, but for the future students I'll post this answer. What Jeremy wrote is right, but in this particular challenge in order to finish it you need to do it on a new line. So you will have something looking like that:

Button loadPuppiesButton = (Button) findViewById(R.id.puppiesButton);
String buttonLabel = "";
loadPuppiesButton.setText("LOAD");
buttonLabel = getString(R.string.morePuppies);
loadPuppiesButton.setText(buttonLabel);

Thanks Suleyman, your answer helped.

Jeremy Faith
PLUS
Jeremy Faith
Courses Plus Student 56,696 Points

The challenge wants you to use the buttonLabel variable to set the text for loadPuppiesButton. Right now it is hard-coded with LOAD. You need to replace "LOAD" in the setText method with buttonLabel.

loadPuppiesButton.setText(buttonLabel);

Hope this helps.

loadPuppiesButton.setText(buttonLabel);

I just thing this is a badly formulated question. God a few of these in the Java Data Structure as well.