How to Display an AlertDialog from a Button

Note: Some of the items in these steps are deprecated.
API Level 1

When a button is pressed an AlertDialog will display.

1. Add an OnClick Action to a Button

2. Add a Deprecated: showDialog to the onClickmyButton method with a constant of ALERT_DIALOG.

3. Add a New Method with a Return Variable, with a method named showAlertDialog and a return variable named Dialog.

4. Add a Deprecated: onCreateDialog method to your class with a case for ALERT_DIALOG and within the case the line below. 

return showAlertDialog();

5. In the showAlertDialog method, Create an AlertDialog with Supplied Arguments

6. Compile and run!

Resources: