-
Notifications
You must be signed in to change notification settings - Fork 29
07 Using custom views
If the class MaterialDialog.Builder should be used to create a "Material Design"-styled custom dialog, the following methods can be used to replace the dialog's child views, which are used to show its title, message, buttons or content (the ListView, which is used to show the list items).
setCustomTitle(View):Builder
setCustomTitle(int):Builder
The setCustomTitle-methods cause the child view, which is used to show the dialog's title and icon, to be replaced by a specific custom view. If the custom view contains a TextView with the id android.R.id.title, the dialog's title will be shown by using this view. Otherwise, the dialog's title will not be shown and the custom can be used for any other purpose.
setCustomMessage(View):Builder
setCustomMessage(int):Builder
The same applies on the setCustomMessage-methods, which allow to replace the view, which is used to show the dialog's message. If the custom view contains a TextView with the id android.R.id.message, the dialog's message will be shown by using this view.
setCustomButtonBar(View):Builder
setCustomButtonBar(int):Builder
The setCustomButtonBar-methods allow to replace the buttons of the dialog. The view should contain three buttons of the type Button. The positive button corresponds to the id android.R.id.button1, the negative button corresponds to the id android.R.id.button2 and the neutral button corresponds to the id android.R.id.button3. If one of the buttons is missing, its functionality is lost.
setView(int):Builder
setView(View):Builder
When the setView-methods are used to specify a custom content view by passing the view itself or the resource id of the corresponding layout resource, the ListView, which is used to show the dialog's list items, will be replaced. If the custom view contains a ListView with the id android.R.id.list, this view will be used to show the dialog's list items. Otherwise, the items cannot be shown.
The following screenshots illustrates how a dialog, whose title and content views have been replaced by custom views, may appear:
