You can use the AlertDialog.Builder class:
http://developer.android.com/reference/android/app/AlertDialog.Builder.html
Create a new instance using AlertDialog.Builder myAlertDialogBuilder = new AlertDialog.Builder(context)
. Then use methods such as setTitle()
and setView()
to customize it. This class also has button customization methods. setPositiveButton(String, DialogInterface.OnClickListener)
to customize the buttons. Finally, use AlertDialog myAlertDialog = myAlertDialogBuilder.create()
to get your instance of AlertDialog, which you can then configure using methods like setCancelable()
.
Edit: Also from the docs: http://developer.android.com/guide/topics/ui/dialogs.html
"The Dialog class is the base class for creating dialogs. However, you usually should not instantiate the dialog box directly. Instead, you should use one of ... subclasses
If you really don't want to use AlertDialog, it is probably best to extend the Dialog class rather than using it as it is.
source share