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

Tuan Zen
Tuan Zen
6,882 Points

use variable to set text?

i have java:104: error: cannot find symbol on this problem but i dont know why. Could someone explain to me what i did wrong?

CodeChallenge.java
Button loadPuppiesButton = (Button) findViewById(R.id.puppiesButton);
String buttonLabel = "";
loadPuppiesButton.setText("LOAD");
buttonLabel = getString(R.string.morePuppies);
Toast.makeText(this, morePuppies, Toast.LENGTH_LONG).show();
strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
  <string name="morePuppies">See More Puppies</string>
</resources>

1 Answer

anil rahman
anil rahman
7,786 Points

You doing toast for task 3? It wants you to use buttonLabel variable you made and use it for the setText instead of that hardcoded value "LOAD".

Toast shows a message on screen for a few seconds.

Button loadPuppiesButton = (Button) findViewById(R.id.puppiesButton);
String buttonLabel = "";

buttonLabel = getString(R.string.morePuppies);
loadPuppiesButton.setText(buttonLabel);
Tuan Zen
Tuan Zen
6,882 Points

ahh thanks i didnt know setText() method works like that