1
I have a button to include a Hint and I have another button to edit the Hint already created. I would like to use the same creation activity, when it is for editing would pull the data already created. I’m in doubt how to do the Intent code, I’m not getting it. It’s not pulling the data. I’m trying it this way:
{ 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 someone help me?
We need a more detailed description of the problem. What is "not pulling the data"? Is there an error? Some line that was supposed to give a result gives another?
– Pablo Almeida
Hi Pablo is the following: I have an Activity - Includica, and another Activity - Tip (with an edit button). The Includica Activity consists of empty Edittexts. Activity Tip, when you click the edit button - I wanted you to open Activity Inclutip with the Hint data in Edittexts. But you’re not pulling the dice.
– Elaine Breda Schwaner
Okay, but the mistake?
– Pablo Almeida
the error is that it is not bringing the data from Intent editardica
– Elaine Breda Schwaner
How did you find out you’re not bringing?
– Pablo Almeida
By the simulator.
– Elaine Breda Schwaner
It would be easier for you to pass information by Bundle. A Boolean, for example, indicating whether the Intent is coming from the edit or add button.
– Max Fratane