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 a Self-Destructing Message Android App Sending Messages Sending the Message

john appleby
john appleby
2,773 Points

declare a String variable and store the value from the mDescriptionField

hey Ben, im a little bit stuck here .... in my understanding this is how you declare a string and add a value to it.... where am I going wrong ?

// Some code omitted!

public void save() {
  ParseObject task = new ParseObject("Task");
  String description = getText(mDescriptionField);
}

}

thanks for any pointers

3 Answers

I hope Ben doesn't mine here...Without giving you the answer, you have to get the value from an "EditText" field and then use additional properties to associate it with a string. I hope this helps.

If you are still stuck google "get value from edittext"

getText() is a method of the EditText class (which mDescriptionField is an object of). So you need to call getText() like this

String description = mDescriptionField.getText().toString();

You have to call toString() because getText() returns an Editable object, so you have to convert that to a string if you want to store it in a string variable.

john appleby
john appleby
2,773 Points

Thanks Ben & Jonathan, now I understand, its just a bit confusing but Ive wrapped my head round that concept now and had a look at some google examples. thanks again for helping me over this wall made of .String