Hi
Can someone explain me why the second if in this code never is executed.
@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(); } } }
The checkbox should be executed in the first "if" if it is checked, or the second if if none are checked...any help please??
Thanks