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 trialRohit Sriram
4,235 PointsCodeChallenge problem
For some reason the editor will not accept my answer. It asks me to make a String description, and put the value of an EditText member variable int called mDescriptionField. My answer was String description = mDescriptionField.toString(); However, it gave me an error saying Bummer! Make sure you get the text from the EditText variable! I do not understand why it gives me this error as I believe this is what I have done. Can somebody please tell me if there is a problem in my code, or how you fixed it.
2 Answers
Rohit Sriram
4,235 PointsNever mind that. I figured out that I needed to add getText() to mDescriptionField.toString().
Rohit Sriram
4,235 Pointsimport android.app.Activity; import android.widget.EditText; import android.widget.Toast; import com.parse.ParseException; import com.parse.ParseObject; import com.parse.SaveCallback;
public class MainActivity extends Activity {
protected EditText mDescriptionField;
protected SaveCallback mSaveCallback = new SaveCallback() {
@Override
public void done(ParseException e) {
Toast.makeText(MainActivity.this, "Item saved!", Toast.LENGTH_SHORT).show();
}
};
// Some code omitted!
public void save() {
ParseObject task = new ParseObject("Task");
String description = mDescriptionField.toString();
}
}
//this is code
The description of the to-do item is stored in the EditText member variable. Declare a string named description and store the value from the EditText in it. Bummer! Make sure you get the text from the EditText variable!
//this is instructions and error
Ankit B
4,180 PointsAnkit B
4,180 PointsDo you want to post the screenshot of the question?