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) User Input Getting Text from an EditText

How to Set the petName variable to the value from the EditText

EditText petNameField = (EditText)findViewById(R.id.petNameField); String petName;

CodeChallenge.java
EditText petNameField = (EditText)findViewById(R.id.petNameField);
String petName;

thank you have been doing that but was using small letters for Name on petNamefield

Ben Junya
Ben Junya
12,365 Points

It happens! Before asking questions, make sure the obvious mistakes like typos and misspellings are taken care of. Go over each line with a fine toothed comb, and if it helps, verbalize it and say out loud what each line of code is doing. I can't tell you how many times I've been frustrated by simple misspellings and capitalizations.

You're on your way man! Good luck!

1 Answer

Ben Junya
Ben Junya
12,365 Points

This is an easy one.

EditText petNameField = (EditText)findViewById(R.id.petNameField);
String petName = petNameField.getText().toString();

The getText() method returns an 'Editable' object, so you need to turn it into a string with toString().

Have fun!