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

Vechnet makuyana
Vechnet makuyana
3,870 Points

Set the petName variable to the value from this EditText.

Were am I going wrong, I had completed this task already and I am doing the same thing I was did on that one but I keep getting compiler error

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

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! You're really close here but you should be using the method getText() to get the text in the text field. There is no method named getpetName. Take a look:

String petName = petNameField.getText().toString();

This will access the TextField we have set up and get the text from it and make it into a string. The result is assigned back into the variable petName.

Hope this helps! :sparkles: