Skip to content

ProgressAlertDialog

Leonardo D. Palma edited this page Mar 27, 2025 · 4 revisions

Create and display a dialog box with circular progress in the dialog container.

Usage

ProgressAlertDialog

In code:

ProgressAlertDialog.Builder(applicationContext)
            .setIcon(R.drawable.ic_resource)
            .setTitle("Lorem Ipsum")
            .setMessage("What is Lorem Ipsum?")
            .setIndeterminable(true)
            .setCancelable(false)
            .setNegativeButton(ButtonIconAlert(R.drawable.ic_resource), object : DialogAlertInterface.OnClickListener {
                override fun onClick(dialog: DialogAlertInterface, whichButton: DialogAlertInterface.UI) {
                    TODO("Not yet implemented")
                }
            })
            .create()
            .show()

Type Style

2 additional entries can be added to the dialog. Which are specified below

  • Alert.Progress.CIRCULAR Show progress in a circular way.

  • Alert.Progress.LINEAR Show progress linearly.

Attributes

ProgressMaterialDialog offers several attributes for a deeper view configuration, the following table shows all these options and their default value.

Name Description Values Default Related method(s)
Builder Creates a builder for an alert dialog that uses the default alert dialog theme Context N/A Builder()
Icon Set the drawable resource to be used in the icon Int N/A setIcon()
Icon Tint Color Set background tint for icon Int or rgb(R,G,B) N/A setIconTintColor()
Icon Tint Color Set background tint for icon IntRes N/A setIconTintColorRes()
Title Set the title displayed String, Int N/A setTitle()
Message Sets the message to display String, Int N/A setMessage()
Details Sets the details to display. Only Linear String, Int N/A setDetailsLinearProgress()
StyleProgress Set style progress Alert.Progress Alert.Progress.CIRCULAR setStyleProgress()
Cancelable Sets whether the dialog is cancelable or not Boolean true setCancelable()
Indeterminable Set whether progress will be indeterminate Boolean false setIndeterminable()
Gravity Set gravity of the dialog Int [android.view.Gravity] N/A setGravity()
Max Set the maximum allowed progress value Int 100 setMax()
NegativeButton Set a listener to be invoked when the negative button of the dialog is pressed String or Int N/A setNegativeButton()
create Creates an ProgressAlertDialog with the arguments supplied to this builder - - create()
show Start the dialog and display it on screen - - show()

If you want to add more functionality to dialog events, you can use the following methods to capture the actions.

  • Create an instance and call the setProgress method to set continuous values. Remember to setIndeterminable() to false.
  • When the dismiss option is called from the dialog box, you can use the setOnDismissListener method to perform additional actions.
  • When the cancel option is called from the dialog box, you can use the setOnCancelListener method to perform additional actions.
  • When the show option is called from the dialog box, you can use the setOnShowListener method to perform additional actions.

Clone this wiki locally