I have a button to add a Tip and I have another button to edit the already created Tip. I would like to use the same Creation Activity, when it is for editing it would pull the data already created. I'm in doubt how to make the Intent code, I can not. You're not pulling the dice. I'm trying like this:
{ Intent novadica = getIntent();
if (novadica==null){
enviardica.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ParseObject dica = new ParseObject("Dicas");
dica.put("nome", edttitulodica.getText().toString());
dica.put("conteudoDica", edtconteudodica.getText().toString());
dica.put("resumo", resumoChamadaDica.getText().toString());
dica.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
Toast.makeText(Inclusaodedica.this, "Dica enviada com sucesso.", Toast.LENGTH_LONG).show();
startActivity(new Intent(getApplicationContext(), MainActivity.class));
}
});
}
});}else{
Intent editardica = getIntent();
String rdicaObjectId = editardica.getStringExtra("dicaObjectId");
final ParseQuery <ParseObject> dica = new ParseQuery<ParseObject>("Dicas");
dica.getInBackground(rdicaObjectId, new GetCallback<ParseObject>() {
@Override
public void done(final ParseObject object, ParseException e) {
edttitulodica.setText(object.getString("nome"));
edtconteudodica.setText(object.getString("conteudoDica"));
resumoChamadaDica.setText(object.getString("resumo"));
enviardica.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
object.put("nome", edttitulodica.getText().toString());
object.put("conteudoDica", edtconteudodica.getText().toString());
object.put("resumo", resumoChamadaDica.getText().toString());
object.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
Toast.makeText(Inclusaodedica.this, "Dica alterada com sucesso.", Toast.LENGTH_LONG).show();
startActivity(new Intent(getApplicationContext(), MainActivity.class));
}
});
}
});
Can anyone help me?