Skip to content

11 The class WizardDialog

Michael Rapp edited this page Dec 27, 2017 · 2 revisions

The class WizardDialog.Builder provides a builder, which allows to create dialogs, which can contain multiple fragments. It is possible to switch between the tabs by either clicking the tabs, which indicate the currently shown fragment, or by using buttons at the bottom of the dialog. Such a dialog can also contain a title, a message and a header. When the dialog contains a header, its tabs can be placed within the header.

In order to add fragments to the dialog, the following methods can be used. Each fragment is identified by its class. Furthermore, it is possible to specify a title for each fragment, which is shown in the dialog's tabs. When using a method, which accepts a Bundle as a paramter, the specified bundle is passed to the corresponding fragment when it is shown.

addFragment(Class<? extends Fragment>):Builder
addFragment(Class<? extends Fragment>, Bundle):Builder
addFragment(CharSequence, Class<? extends Fragment>):Builder
addFragment(CharSequence, Class<? extends Fragment>, Bundle):Builder
addFragment(int, Class<? extends Fragment>):Builder
addFragment(int, Class<? extends Fragment>, Bundle):Builder

For configuring the dialog's title and message, methods, which are similar to those of the class MaterialDialog.Builder are provided by the builder WizardDialog.Builder. Besides those methods the following ones allow to change the properties of a WizardDialog.

Setter methods Description Default value Restrictions
setTabPosition(TabPosition):Builder Sets the position of the dialog's tabs. TabPosition.PREFER_HEADER The position may not be null.
enableTabLayout(boolean):Builder Sets, whether the dialog's tabs should be clickable, or not. false none
showTabLayout(boolean):Builder Sets, whether the dialog's tabs should be shown, or not. true none
setTabIndicatorHeight(int):Builder Sets the height of the indicator, which indicates the currently shown fragment. 2dp The height must be at least 1.
setTabIndicatorColor(int):Builder Sets the color of the indicator, which indicates the currently shown fragment. R.attr.colorAccent Must be a valid color, not a resource ID.
setTabTextColor(int):Builder Sets the text color of the dialog's tabs. android.R.attr.textColorSecondary Must be a valid color, not a resource ID.
setTabSelectedTextColor(int):Builder Sets the selected text color of the dialog's tabs. android.R.attr.textColorSecondary Must be a valid color, not a resource ID.
enableSwipe(boolean):Builder Sets, whether switching between fragments should be possible by using swipe gestures, or not. true none
showButtonBar(boolean):Builder Sets, whether the dialog's buttons should be shown, or not. true none
setBackButtonText(CharSequence):Builder setBackButtonText(int):Builder Sets the text of the back button. R.string.back_button_text Must neither be null, nor empty. When specified as a resource ID, the ID must correspond to a valid string resource.
setNextButtonText(CharSequence):Builder setNextButtonText(int):Builder Sets the text of the next button. R.string.next_button_text Must neither be null, nor empty. When specified as a resource ID, the ID must correspond to a valid string resource.
setFinishButtonText(CharSequence):Builder setFinishButtonText(int):Builder Sets the text of the finish button. R.string.finish_button_text Must neither be null, nor empty. When specified as a resource ID, the ID must correspond to a valid string resource.

As an alternative to using the setter methods shown above, theme attributes, which are shown in the table below, can be used to change the appearance of the dialog.

Theme attribute Description Format
materialDialogTabPosition Specifies the position of the dialogs' tabs. enum
materialDialogEnableTabLayout Specifies, whether the dialog's tabs should be clickable, or not. boolean
materialDialogShowTabLayout Specifies, whether the dialog's tabs should be shown, or not. boolean
materialDialogTabIndicatorHeight Specifies the height of the indicator, which indicates the currently shown fragment. dimension
materialDialogTabIndicatorColor Specifies the color of the indicator, which indicates the currently shown fragment. color
materialDialogTabTextColor Specifies the text color of the dialog's tabs. color
materialDialogTabSelectedTextColor Specifies the selected text color of the dialog's tabs. color
materialDialogEnableSwipe Specifies, whether switching between the dialog's fragments is possible by using swipe gestures, or not. boolean
materialDialogShowButtonBar Specifies, whether the dialog's buttons should be shown, or not. boolean
materialDialogBackButtonText Specifies the text of the back button. string
materialDialogNextButtonText Specifies the text of the next button. string
materialDialogFinishButtonText Specifies the text of the finish button. string