A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed.
3 most used dialog window are:
Here is code to create an Alert dialog:
Here is code to create a confirm dialog:
Here is code to create a prompt dialog:
In this example, I've demonstrated Alert dialog, Confirm dialog and Prompt dialog.
Step 1: Create a new project in Android Studio and name it Android dialogs.
Step 2:Open res -> drawable -> activity_main.xml and replace the code with code of activity_main.xml with the below given code.activity_main.xml
Step 3: Open MainActivity.java and replace its code with below given code.
Step 4:Clean and run your project to see the result.