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 trialsteve apgar
Courses Plus Student 568 Pointshelp please
need stepbystep help, please and thank you
Button loadPuppiesButton = (Button) findViewById(R.id.puppiesButton);
String buttonLabel = "";
loadPuppiesButton.setText("LOAD");
<?xml version="1.0" encoding="utf-8"?>
<resources>
</resources>
1 Answer
karis hutcheson
7,036 PointsOkay, I went back and re-took the challenge. Here's an explanation of each step:
- You need to create a new string in the strings.xml file named "morePuppies". In XML we store data by putting it between tags (<tag> data </tag>). In Android Dev, you'll store this in a <string> tag with an attribute of name like so:
<resources>
<string name="morePuppies">more puppies</string>
</resources>
- We need to access this data in our Java code. We do this using the getString(int) method where int is the integer ID of the string data we want to use. We'll get that using R.string.stringName and we'll put it all together like so:
buttonText = getString(R.string.morePuppies);
- Finally, we set the text of the button using the Button method setText(String) where String is the text we want to see in the button.
button.setText(buttonText);
karis hutcheson
7,036 Pointskaris hutcheson
7,036 PointsIt would help a lot if you gave us a description of what you're trying to do.