-
-
Notifications
You must be signed in to change notification settings - Fork 18
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) -
Buttons
Positive button:.pos(String label),.pos(int resId)
Negative button:.neg(String label),.neg(int resId),.neg()
Neutral button:.neut(String label),.neut(int resId),.neut()
Passnullto 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 you main App-Theme. -
Extras
extra(Bundle extras)
Supply additional data that are added to the results (see Receiving results)
Use these methods to display the dialog in your activity or fragment. Supply an optional tag if you want to match results to your dialog (see Receiving results)
show(Fragment fragment);
show(Fragment fragment, String tag);
show(AppCompatActivity activity);
show(AppCompatActivity activity, String tag);Let your activity or fragment implement the OnDialogResultListener to receive results:
@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. For other dialog types also values such as a text that was entered will be included. See the documentation of these dialogs for details.
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