-
-
Notifications
You must be signed in to change notification settings - Fork 17
SimpleDialog
- Call the
build()
method of the dialog - Customize the dialog as needed using the methods described below
- Show the dialog via
show()
SimpleDialog.build()
.title(R.string.hello)
.msg(R.string.hello_world)
.show(Activity.this);
-
Title
.title(String title)
,.title(int resId)
-
Message
.msg(String message)
,.msg(int resId)
You can also pass styled strings containing html tags using one of:
.msgHtml(String message)
,.msgHtml(int resId)
-
Buttons
.pos(String label)
,.pos(int resId)
(positive button)
.neg(String label)
,.neg(int resId)
,.neg()
(negative button)
.neut(String label)
,.neut(int resId)
,.neut()
(neutral button)
Passnull
to hide a button. The positive Button is shown by default unless you hide it. -
Icon
icon(int resId)
-
Cancelable
cancelable(boolean cancelable)
Controls weather the dialog may be suppressed by touching outside of it. -
Theme
theme(int resId)
Set custom themes on a per-dialog-basis. You can also specify a global theme with thealertDialogTheme
-Attribute in your main App-Theme (see styles.xml in the example application). -
Extras
extra(Bundle extras)
Supply additional extras that are added to the results (see Receiving results)
Use these methods to display the dialog in your activity or fragment.
The tag is required, if you want to get results from your dialog (see Receiving results).
The methods without a tag are only meant for simple informative dialogs.
show(Fragment fragment);
show(Fragment fragment, String tag);
show(FragmentActivity activity);
show(FragmentActivity activity, String tag);
Let your activity or fragment implement the OnDialogResultListener
to receive results.
Please note that before v2.3 the result listener was only called, if a tag was supplied to the show
method.
Starting with v2.3 the dialog's TAG
field will be used as default tag (WARNING: Not passing a TAG is unreliable, see #42)
@Override
public boolean onResult(@NonNull String dialogTag, int which, @NonNull Bundle extras) {
if (MY_DIALOG_TAG.equals(dialogTag)){
switch(which){
case BUTTON_POSITIVE:
// ...
break;
case BUTTON_NEGATIVE:
// ...
break;
// ...
}
return true;
}
return false;
}
The extras
Bundle will contain all extras supplied when building the dialog.
Additional extras will be added depending on the dialog type (e.g. the entered text for an input-dialog).
See type-specific documentation for details.
Return true
from this method if the result was handled, false
otherwise.
Javadoc API
Screenshot gallery
Styling dialogs with themes
Fullscreen dialogs
SimpleDialog
CustomViewDialog
CustomListDialog
SimpleCheckDialog
SimpleColorDialog
SimpleColorWheelDialog
SimpleDateDialog
SimpleEMailDialog
SimpleFormDialog
SimpleImageDialog
SimpleInputDialog
SimpleListDialog
SimplePinDialog
SimpleProgressDialog
SimpleTimeDialog