Android alertDialog

label Programming
account_circle Unassigned
schedule 3 Days
account_balance_wallet $5

Hi, what's wrong with this code, the second if doesn't work

@SuppressWarnings("deprecation")

public void showAnulacao(View v) {

String result = "Os dias anulados foram:";

Double totalAmount = 0.0;

for (Refeicao p : boxAdapter.getBox()) {

if (p.selected) {

result += "\n" + p.dia;

totalAmount += p.preco;

AlertDialog alertDialog = new AlertDialog.Builder(CantinaDiurnoActivity.this).create();

alertDialog.setTitle("Informação");

alertDialog.setMessage(result + "\n" + "Creditamos-lhe: " + totalAmount + "€");

alertDialog.setIcon(R.drawable.tick);

alertDialog.setButton("OK", new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int which) {

finish();

}

});

alertDialog.show();

}

if(!p.selected){

AlertDialog alertDialog = new AlertDialog.Builder(CantinaDiurnoActivity.this).create();

alertDialog.setTitle("Erro!");

alertDialog.setMessage("Não efetuou nenhuma seleção!");

alertDialog.setIcon(R.drawable.delete);

alertDialog.setButton("OK", new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int which) {

finish();

}

});

alertDialog.show();

}

}

}


Nov 30th, -0001
Why not replace the second if with a simple 'else'?

When you say it is not working, what is happening?
Jun 11th, 2013

Studypool's Notebank makes it easy to buy and sell old notes, study guides, reviews, etc.
Click to visit
The Notebank
...
Nov 30th, -0001
...
Nov 30th, -0001
Jun 23rd, 2017
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer