Skip to content

MaterialAlertDialogInput

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

Create and display a dialog box with the basics of entering data.

Usage

MaterialAlertDialogInput

In code:

MaterialAlertDialogInput.Builder(applicationContext)
            .setIcon(R.drawable.ic_resource)
            .setTitle("Lorem Ipsum")
            .setMessage("What is Lorem Ipsum?")
            .setCancelable(false)
            .setPositiveButton(ButtonIconAlert(R.drawable.ic_resource), object : DialogAlertInterface.OnClickInputListener {
                override fun onClick(dialog: DialogAlertInterface, content: String) {
                    TODO("Not yet implemented")
                }
            })
            .create()
            .show()

Mask

For create your mask you need to use following keys:

  • ANYTHING KEY = *
  • DIGIT KEY = #
  • UPPERCASE KEY = U
  • LOWERCASE KEY = L
  • ALPHA NUMERIC KEY = A
  • CHARACTER KEY = ?
  • HEX KEY = H

For example: You would like create a mask for a mobile number in format (029)777-77-77. Just use the simple mask "(###)###-##-##".

Attributes

MaterialAlertDialogInput 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()
MaskedFormatter Set masked formatter String N/A setMaskedFormatter()
Count Down Timer Set a countdown on one of the buttons (DialogAlertInterface.UI, Long) N/A setCountDownTimer()
CounterMaxLength Set counter-max length Int N/A setCounterMaxLength()
StartIcon Set an icon at the start (@DrawableRes, String, listener?) N/A setStartIconLayoutInput()
EndIcon Set an icon at the end (@DrawableRes, String, listener?) N/A setEndIconLayoutInput()
HintText Set input hint R.string.text_value_enter_a_value_below String, Int setInputHint()
HelperText Set input helper text N/A String, Int setInputError()
ErrorText Set input error N/A String, Int setInputHelperText()
DefaultText Set input default value N/A String setInputDefaultValue()
Box Corner Set the corner radius of the TextInputLayout float N/A setBoxCornerRadius()
Gravity Set gravity of the dialog Int [android.view.Gravity] N/A setGravity()
Cancelable Sets whether the dialog is cancelable or not Boolean false setCancelable()
PositiveButton Set a listener to be invoked when the positive button of the dialog is pressed String or Int N/A setPositiveButton()
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 MaterialAlertDialogInput 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.

  • 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