dialog is usually a small window that appears in front of the current Activity. The underlying Activity loses focus and the dialog accepts all user interaction. Dialogs are normally used for notifications that should interrupt the user and to perform short tasks that directly relate to the application in progress .
The Dialog class is the base class for creating dialogs.
Types of default dialog boxes are:
• AlertDialog
• ProgressDialog
• DatePickerDialog
• TimePickerDialog

If we wish to create a customized dialog box then we can do so in the following way:

Step 1. Create a xml layout for the dialog box and a transparent background is preferable in order to show the Activity screen underneath it.

dialog_screen.xml

<RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:background=”@drawable/bg_dialog” >

<ImageView
android:id=”@+id/dialogImgView_id”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_alignParentBottom=”true”
android:background=”@drawable/mid_box” />

<ImageButton
android:id=”@+id/ImgBtn2_id”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_alignTop=”@+id/ImgBtn1_id”
android:background=”@drawable/female_selector” />

</RelativeLayout>

Step2. Add the following code for dialog box in oncreate(),onclick() etc based on where you want the dialog box to pop. In the given example the dialog box appears as soon as the activity starts .Hence, the code is placed in oncreate() .

public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.play_menu_screen);//setting layout foractivity

//put your activity related code here

Dialog(); //function call for dialog box

}

/*code for creating a custom dialog box */

private void Dialog()
{
/* creating a dialog object and specifying the activity it pops on .
PlayActivity is the activity on which dialog box appears & R.style.FullHeightDialog
Specifies that dialog box has height equivalent to screen height */

final Dialog dialog = new Dialog(PlayActivity.this,R.style.FullHeightDialog);

dialog.setContentView(R.layout.dialog_screen);//setting the dialog xml layout

/* adding action when image buttons of dialog are clicked */

dialog.findViewById(R.id.ImgBtn_id).setOnClickListener(
new OnClickListener() {
public void onClick(View v) {

//put your code here

dialog.dismiss();//closes the dialog box
}
});

dialog.show();//pops the dialog box

}
This way we can create a customized dialog box .Why use the boring default dialog boxes when we can create our own.