0

Other code is working but alert dialogue is not showing.

Code:

AlertDialog.Builder confirm = new AlertDialog.Builder(MainActivity.this);

                confirm.setTitle("Do you confirm this order?");
                confirm.setMessage(order);
                confirm.setCancelable(true);
                confirm.setPositiveButton("Confirm", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        orderId ++;
                        orderConfirmed = order;
                        order = "";
                    }
                });
AskNilesh
  • 67,701
  • 16
  • 123
  • 163

3 Answers3

0

You need to add .show() behind confirm.

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
Caspar Geerlings
  • 1,021
  • 2
  • 10
  • 21
0

One important call is missing, do - confirm.show()

Aarth Tandel
  • 1,001
  • 12
  • 32
0
AlertDialog.Builder confirm = new AlertDialog.Builder(MainActivity.this);

confirm.setTitle("Do you confirm this order?");
confirm.setMessage(order);
confirm.setCancelable(true);

confirm.setPositiveButton("Confirm", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
        orderId ++;
        orderConfirmed = order;
        order = "";
     }
  });
AlertDialog.show();

hope this may help you

AskNilesh
  • 67,701
  • 16
  • 123
  • 163
InsaneCat
  • 2,115
  • 5
  • 21
  • 40