Learn how to implement custom layout in android AlertDialog. To inflate custom view in alertdialog i am using AlertDialog.Builder class to create dialog box.

Step 1. Create new project in android and add button on your main actvity.

Step 2. Create new Layout file in res folder, this is our view which we inflate in AlertDialog.

Step 3. Now open your MainActivity.java file and add OnClickListener on button and when user click on button we create popup.

Add custom layout in AlertDialog Code:

To hide popup you call myDialog.hide().

🙂