-
-
Notifications
You must be signed in to change notification settings - Fork 18
SimpleFormDialog
extends CustomViewDialog

A Dialog that can be used to create simple or more complex forms.
One can either use one of the following predefined dialogs or use an arbitrary combination of fields as shown below.
- Login dialog (username or email)
- Email input
- Password input
- Number input
SimpleFormDialog.buildLogin(USERNAME, PASSWORD)
.show(this, LOGIN_DIALOG);
SimpleFormDialog.build()
.title(R.string.register)
.msg(R.string.please_fill_in_form)
.fields(
Input.name(NAME).required().hint(R.string.name),
Input.password(PASSWORD).required().max(20).validatePatternStrongPassword(),
Input.email(EMAIL).required(),
Input.plain(COUNTRY).hint(R.string.country)
.inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES)
.suggest(R.array.countries_locale).forceSuggestion(),
Check.box(null).label(R.string.terms_accept).required()
)
.show(this, REGISTRATION_DIALOG);
FormElements can be added using the .fields(FormElement...)
method as shown above.
Each FormElement gets assigned a custom key-string when created. You can receive the entered value in onResult
using this key (see below).
You can also mark every form element as required, so that the user cannot continue, until text was entered, the checkbox checked or a value from the spinner chosen.
The following predefined FormElements exists, but new ones can easily be created by extending the FormElement
and FormElementViewHolder
classes:
-
Input fields
Input
Options: Hint, initial text, min/max length, suggestions, password visibility toggle button, regular expression based pattern validation
Required flag: requires this field to contain non white-space text -
Checkboxes
Check
Options: Label, initial state
Required flag: requires this field to be checked -
Spinners
Spinner
Options: Items, label, place-holder text if nothing is selected, initially selected item
Required flag: requires a value to be chosen. This will remove the place-holder text from the list of choice
In onResults
get the entered values from the Bundle like this:
String text = extras.getString(INPUT_KEY);
boolean checked = extras.getBoolean(CHECKBOX_KEY);
int selected = extras.getInt(SPINNER_KEY);
See SimpleDialog
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