An alert box is used to show a message to user and also sometimes getting suitable reply like yes, no, cancel. In alert boxes we can set three types of buttons like

Beside these buttons you can also set a Title for your alert-box, and a message which is to be displayed.

 

MainActivity.java

 

  Add textview and button to xml screen.

activity_main.xml

AndroidManifest.xml

Output :

alert-box1

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

Close