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 trialHarley Privitera
13,316 PointsI don't see what I'm doing wrong in this challenge
Here is the challenge:
Challenge Task 3 of 4
Now put the description string in your ParseObject using the key "description". Bummer! Make sure you use the correct key and value from the instructions. Preview
It looks right to me, what am I missing?
import 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 obj = new ParseObject("Task");
String description = "foo";
obj.put(description, mDescriptionField.getText());
obj.put("description", description);
}
}
3 Answers
Steve Hunter
57,712 PointsFor task 3 of 4, my code looks like:
public void save() {
ParseObject obj = new ParseObject("Task");
String description = mDescriptionField.getText().toString();
obj.put("description", description);
}
I hope that helps.
Steve.
Harley Privitera
13,316 PointsThank you both; I misunderstood task 2, that's what threw me off, as task 2 completed successfully for me.
My task 2 was the my original code without the second obj.put() call.
Harry James
14,780 PointsHey there John!
You almost got it! Just a little tweak is needed on this line:
obj.put(description, mDescriptionField.getText());
We've got the text but, this returns a value of the Editable
type and, we want to put in as a String
.
So, we somehow need to do a conversion here. I'll leave that to you.
Hopefully this hint should help you out but, if you don't know what to do still, give me a shout and I'll help you out :)