1. Introduction :

Generally we see popup boxes appearing in the apps showing alert messages or system errors. And also sometimes we can enter data into these windows which can be further processed depending upon our requirement.




You can see the below window which is the popup we are going to learn in this tutorial.

The popup box intakes a text i.e., your name and will display a toast when ok button is clicked and popup box is closed when cancel button is clicked.

And also you can notice we have placed a logo and heading you can change the design according to your requirement. We can also display listview in the popup box that we will see in our further tutorials, not only listview we can show maps, images, and many more….

2. Creating activity_main.xml :

Add a textview and a button to the activity.


3. Creating MainActivity.java :

We will be calling the pop up box on button click in mainactivity.


4. Creating popup.xml :

Now we will be creating popup activity by adding imageview for logo and textviews, button and edittext for accepting text to be displayed as toast.


5. Creating popup.java :


Initialize buttons, edittext and setOnClickListener for two buttons.


6. AndroidManifest :

Add popup activity as



7. Output :

popup3 popup2

Show Buttons
Hide Buttons
Read previous post:
Android Tutorial on AutoCompleteTextView