Reputation: 1688
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
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