MrEngineer13
MrEngineer13

Reputation: 38856

Android-Alert Dialog not working

For some reason, I can not get this dialog to show up on the screen. It is triggered by a button press which I know works but the dialog doesn't launch, why not?

     AlertDialog.Builder builder = new AlertDialog.Builder(SummaryActivity.this);
      builder.setTitle(R.string.please_confirm)
             .setMessage(R.string.terms_details)
             .setCancelable(false)
             .setPositiveButton(R.string.sign_to_agree, new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface dialog, int id) {        
                    Intent DrawIntent = new Intent(getApplicationContext(), DrawingActivity.class);
                    startActivity(DrawIntent);
               }
           })
           .setNegativeButton(R.string.cancel_button_label, new DialogInterface.OnClickListener() {
               public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
               }
           });
     AlertDialog alert = builder.create();

Upvotes: 1

Views: 1252

Answers (3)

Jameer Mulani
Jameer Mulani

Reputation: 2303

You forgot to display your dialog alert, use show() of AlertDialog
add this to end of your code alert.show();

Upvotes: -1

Sumant
Sumant

Reputation: 2795

add

alert.show();

after

 AlertDialog alert = builder.create();

this code then u r dialog will be shown on screen.

Upvotes: 4

Heiko Rupp
Heiko Rupp

Reputation: 30934

You need to add

alert.show();

at the end to actually get it on screen

Upvotes: 1

Related Questions