In this blog, we are going to learn how to build AlertDialog and Custom dialog in android with kotlin language. you should have basic knowledge of kotlinActivity, and Fragment.

What is a Dialog?

A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog is normally used for modal events that require users to take an action before they can proceed. for example, to confirm a user logout we can use AlertDialog, to pick a date we can use DatePickerDialog, to pick a time we can use TimePickerDialog**, **fordownloading information we can use ProgressDialog or we can use custom dialog to contain more information by using DialogFragmentclass.

There are two main classes for dialogs in android.

android.app.Dialog and androidx.fragment.app.DialogFragment. **Dialog **Class contains AlertDialog(Confirmation Dialog)DatePickerDialogTimePickerDialogProgressDialog and DialogFragment class contains custom dialog.

Best Practice to use Dialog

  1. Avoid Scrollable Dialog.
  2. Avoid Multiple dialogs on a single screen.
  3. Do not open Dialog automatically.
  4. Do not create confusion user action.

Let’s see what is AlertDialog

#custom-dialog #dialogfragment #alertdialog #android-dialog

AlertDialog and CustomDialog in Android With Kotlin.
5.25 GEEK