Dialogs | How to Show Alert Dialog in Android

Dialogs | Definition 

A dialog is a small window that prompts the user to make a decision or enter additional information. 

The full source code is available here.

Creating AlertDialog is very simple. In this tutorial I'll be discussing about creating Alert Dialogs with the following categories.
  1. Single Button
  2. Two Buttons
  3. Three Buttons

1. Single Button - Alert Dialog

         The following code will be create a simple alert dialog with one button. Sometimes your application is need to indicate such as the process is completed, phone contact list is loaded, etc

In Java



     

In Kotlin


This result of above code will be like following image.



2. Two Buttons - Alert Dialog


         The following code will be create a simple alert dialog with two buttons. Sometimes your application is need to ask such as remove file from the database or the file manager, etc



In Java


In Kotlin







This result of above code will be like following image.



3. Three Buttons - Alert Dialog


         The following code will be create a simple alert dialog with three buttons. Sometimes your application is need to ask save some file to the database.


In Java





In Kotlin


This result of above code will be like following image.


Showing toast function:

In Java




In Kotlin




This output of above code will display like following image



The full source code is available here.

Dialogs | How to Show Alert Dialog in Android Dialogs |  How to Show Alert Dialog in Android Reviewed by Unknown on February 14, 2018 Rating: 5

No comments:

Powered by Blogger.