1
Every time I click on Toolbar I have a menu that when clicking on one of the options I see a AlertDialog
. This Alertdialog has a setSingleChoiceItems
, where the user choosing an option and clicking OK, this option is saved in the BD.
All this works well. The problem is that when returning to the activity I want to q appear different information depending on the choice that the user made in Alertdialog and I am not able to.
I’m using the Onresume()
mes = (TextView) findViewById(R.id.textMes);
metaDef = (TextView) findViewById(R.id.textMetaDef);
despesa = (TextView) findViewById(R.id.textDesp);
if (db_helper.hasMoeda()) {
moeda = db_helper.getMoeda();
} else {
db_helper.updateMoeda("Euro");
}
Gasto gasto=new Gasto();
gasto=db_helper.getGasto();
mes.setText(gasto.getMes());
if (moeda.equalsIgnoreCase("Euro")) {
metaDef.setText("" + gasto.getMeta() + " €");
despesa.setText(String.format("%.2f €", gasto.getDespesa_final()));
} else if (moeda.equalsIgnoreCase("Real")) {
metaDef.setText("R$ " + gasto.getMeta());
despesa.setText(String.format("R$ %.2f", gasto.getDespesa_final()));
}
What is happening is that the activity is not updated when I click on the OK of the alertDialog. Does anyone have any suggestions?
Is a Alertdialog or a Dialogfragment?
– ramaral
@ramaral , Alertdialog..... Alertdialog.Builder Builder=new Alertdialog.Builder(this);
– porthfind
Then you should update the information from Activity in the method
onClick()
button OK of Alertdialog and not in theonResume()
– ramaral
@ramaral, my Alertdialog is in another class, in that class I have an onClick but it is to validate the option that user chooses. The problem is that when I left Alertdialog I wanted to be made a kind of refresh in the activity...then use onResume()
– porthfind
In what other class? Other Activity or a class inherited from Alertdialog. Please rephrase the question in order to have all the information.
– ramaral
the information chosen in the dialod should reflect in Activity... is it? choose in the dialog and change something in Activity when closing the dialog... that’s it?
– FlipNovid
@Flipnovid when clicking the Alertdialog Ok when I return the activity should show a certain information that does not show...(in Alertdialog the user chooses the currency...when he returns to the Activity he should execute the part of the if code (currency.equalsIgnoreCase("Euro").... and does not perform)
– porthfind
You should call back in your dialog.. Has Jah done this before? Want me to post it here? so on the return of your dialog or on your click changes the value in Activity
– FlipNovid
when the dialog is closed Activity or Fragment is not entering your onResume...this is clear
– FlipNovid
@Flipnovid thank you, I will investigate! :)
– porthfind
@porthfind managed to solve?
– FlipNovid
@Flipnovid I will see this fds
– porthfind
@porthfind ok... anything calls here... that I put an example... put if succeeded
– FlipNovid
@Flipnovid can for example pf? I can’t solve my problem :\
– porthfind