-
Notifications
You must be signed in to change notification settings - Fork 29
02 Specifying a title, icon and message
In order to create a MaterialDialog
, an instance of the class MaterialDialog.Builder
has to be created at first. The builder therefore provides the constructor Builder(Context)
, which expects an instance of the class Context
as a parameter.
To specify the title of the dialog, which should be created by the builder, the following two methods can be used. One of them allows to pass the title as an instance of the type CharSequence
, the other one expects the resource id of a string resource as a parameter.
setTitle(CharSequence):Builder
setTitle(int):Builder
Specifying the message of a dialog is very similar to specifying the dialog's title. The following methods, which either allow to pass an instance of the type CharSequence
or the resource id of a string resource, can be used.
setMessage(CharSequence):Builder
setMessage(int):Builder
To show an icon to the left of the dialog's title, the following three methods can be used. The icon is also shown if no title is specified.
setIcon(Bitmap):Builder
setIcon(int):Builder
setIconAttribute(int):Builder
The setIcon
-methods shown above allow to specify the icon by either passing an instance of the class Bitmap
or the resource id of a drawable resource as a parameter. The setIconAttribute
-method allows to pass the an attribute of the theme, which is applied on the builder to specify the icon. An example of such an attribute is android.R.attr.alertDialogIcon
.