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 trialBart Kluczynski
15,326 PointsNo 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!
Button loadPuppiesButton = (Button) findViewById(R.id.puppiesButton);
String buttonLabel = getString(R.string.morePuppies);
String buttonLabel = loadPuppiesButton.setText("LOAD");
// String name = mNameField.getText().toString();
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="morePuppies">See More Puppies</string>
</resources>
5 Answers
Suleyman Orazgulyyev
Courses Plus Student 5,798 PointsHey, 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);
Jeremy Faith
Courses Plus Student 56,696 PointsThe 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.
Suleyman Orazgulyyev
Courses Plus Student 5,798 PointsI'm glad it helped :) happy coding!
Patrick Munemo
14,892 PointsloadPuppiesButton.setText(buttonLabel);
chelaru adrian
Courses Plus Student 2,229 PointsI just thing this is a badly formulated question. God a few of these in the Java Data Structure as well.
Jonathan Barnthouse
2,801 PointsJonathan Barnthouse
2,801 PointsThanks Suleyman, your answer helped.