Dialog is used to show pop up Dialog box to the user in the current Activity. In this tutorial we are going to show you how to implement Custom Dialog box with input text fields and buttons.
Make sure you have properly setup the Android SDK, AVD for Testing the Application. Create a New project in Eclipse IDE with the package as “learn2crack.customdialog“. Create the Main Activity as “MainActivity” and the main Layout as “activity_main“.
First we are importing the layout items. On button click we are displaying the pop up dialog. Here the custom Dialog is named as “custom”, which is defined by “custom = new Dialog(MainActivity.this)”. Then “.setTitle” is to set title message and “.contentView” is used to display the custom xml layout that we created. When the text is entered in the field and save is pressed, it is displayed in TextView in the MainActivity.