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
  • 63,753
  • 16
  • 113
  • 150

3 Answers3

0

You need to add .show() behind confirm.

AskNilesh
  • 63,753
  • 16
  • 113
  • 150
Caspar Geerlings
  • 959
  • 2
  • 9
  • 21
0

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

Aarth Tandel
  • 951
  • 11
  • 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
  • 63,753
  • 16
  • 113
  • 150
InsaneCat
  • 2,012
  • 5
  • 19
  • 35