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 trialMUZ140564 Kudakwashe Jena
4,895 PointsFinally, save this ParseObject in the background and pass in the mSaveCallback member variable.
May u please help ,me i am stuck.
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 mTask .new ParseObject("Task");
// parseObject.saveInBackground(mSaveCallbck); // duplicate code?
String description = mDescriptionField.getText().toString();
mTask.put("description", description);
mTask.saveInBackground(mSaveCallbck); // this is correct but the callback is called mSaveCallback
}
}
1 Answer
Harry James
14,780 PointsHey there!
You were close! There's just a few typos in your code:
ParseObject mTask .new ParseObject("Task");
// You used a . instead of an = here!
parseObject.saveInBackground(mSaveCallbck);
// You don't need to save in background yet - delete this on the second line of the save() method.
mTask.saveInBackground(mSaveCallbck);
// Here, mSaveCallbck should be mSaveCallback
These should be all of the issues you had and you should be able to pass the challenge. Hope it helps and if there's anything else, give me a shout :)
MUZ140564 Kudakwashe Jena
4,895 PointsMUZ140564 Kudakwashe Jena
4,895 PointsThank u so much.I did not even realise i wrote Callbck instead of Callback until u pointed it out.lol
Harry James
14,780 PointsHarry James
14,780 PointsHaha! Glad to hear you got passed the challenge then :)