Calgar99
Calgar99

Reputation: 1688

Android: No response from dialog

I'm trying to get a dialog option to popup on the click of a button "delete". However when I click the button I get no response. There are no errors occurring I'm wondering if I am missing something completely.

  deleteModule = (Button)findViewById(R.id.deleteButton);
        deleteModule.setOnClickListener(this);
    }

    public void onClick (View deleteModule) 
    {
         Dialog(rowId);


    }

    public void Dialog (final String rowId) {
        // Use the Builder class for convenient dialog construction
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage(R.string.confirmDelete)
               .setPositiveButton(R.string.confirmDelete, new DialogInterface.OnClickListener() {
                   public void onClick(DialogInterface dialog, int id) {
                     MODULEDATABASE = new database(ViewCourse.this);
                     MODULEDATABASE.deleteRow(rowId);
                     Intent intent = new Intent(ViewCourse.this, MyCourses.class);
                     startActivity(intent);

                   }
               })
               .setNegativeButton(R.string.confirmDelete, new DialogInterface.OnClickListener() {
                   public void onClick(DialogInterface dialog, int id) {
                      dialog.cancel();
                   }


  }).create();
}

Upvotes: 1

Views: 178

Answers (2)

Luke Taylor
Luke Taylor

Reputation: 9599

You have to call the show() method on the builder to make the dialog visible. Here is more information on creating and displaying dialogs : http://developer.android.com/guide/topics/ui/dialogs.html

I hope this helps.

Upvotes: 0

Nesim Razon
Nesim Razon

Reputation: 9794

I think you need to add:

builder.show()

Upvotes: 1

Related Questions