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 trialVechnet makuyana
3,870 PointsSet 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
EditText petNameField = (EditText)findViewById(R.id.petNameField);
String petName = petNameField.getpetName().toString();
1 Answer
Jennifer Nordell
Treehouse TeacherHi 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!