dismiss() - How to Dismiss an AlertDialog

public abstract void dismiss () was added in API level 1
This will close an AlertDialog box.

An AlertDialog with a Positive button, Negative button, or Neutral button will close automatically when the button is clicked. Even using a List of Items the AlertDialog will close automatically upon selection.
However, in a List of Single Choice Items, or List of Multi-Choice Items, the AlertDialog will not NOT automatically close upon user selection. Therefore, we can use a dismiss() for this.

1. Add a List of Single Choice Items.

2. Add the line below to the imports section.

import android.app.AlertDialog; 

3. In the onClick, add the line below to close the AlertDialog.

dialog.dismiss();

4. Compile and run!

Resources:
http://developer.android.com/reference/android/content/DialogInterface.html#dismiss()