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 trialYvett Chahwanda
5,302 PointsHow to Set the petName variable to the value from the EditText
EditText petNameField = (EditText)findViewById(R.id.petNameField); String petName;
EditText petNameField = (EditText)findViewById(R.id.petNameField);
String petName;
Ben Junya
12,365 PointsIt 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
12,365 PointsThis 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!
Yvett Chahwanda
5,302 PointsYvett Chahwanda
5,302 Pointsthank you have been doing that but was using small letters for Name on petNamefield