SimpleDialogFragments Library is a collection of easy to use and extendable DialogFragment's for Android.
It is fully compatible with rotation changes and can be implemented with only a few lines of code.
A new approach of result handling ensures data integrity over rotation changes, that many other library lack.
Version history and JavaDoc API
- Common dialogs like
- Alert dialogs with optional checkbox
- Input dialogs with suggestions and validations
- Filterable single- / multi-choice dialogs
- Color pickers
- Date and time pickers
- Customizable and extendable dialogs
- Material design
- Easy resut handling even after rotation changes
- Persistant on rotation
In your build.gradle file:
dependencies {
compile 'com.github.eltos:simpledialogfragment:1.1'
}Alert dialog
SimpleDialog.build()
.title(R.string.hello)
.msg(R.string.hello_world)
.show(MainActivity.this);Choice dialog
int[] data = new int[]{R.string.choice_A, R.string.choice_B, R.string.choice_C};
SimpleListDialog.build()
.title(R.string.select_one)
.choiceMode(ListView.CHOICE_MODE_SINGLE_DIRECT)
.items(getBaseContext(), data)
.show(MainActivity.this, LIST_DIALOG);Input dialog
SimpleInputDialog.build()
.title(R.string.login)
.hint(R.string.password)
.pos()
.neut()
.max(25)
.inputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD)
.show(LoginFragment.this, PASSWORD_DIALOG);See Wiki for more examples.
###Receive Results
Let the hosting Activity or Fragment implement the SimpleDialog.OnDialogResultListener
@Override
public boolean onResult(@NonNull String dialogTag, int which, @NonNull Bundle extras) {
if (which == BUTTON_POSITIVE && PASSWORD_DIALOG.equals(dialogTag)){
String pw = extras.getString(SimpleInputDialogFragment.TEXT);
// ...
return true;
}
if (which == BUTTON_POSITIVE && LIST_DIALOG.equals(dialogTag)){
ArrayList<Integer> pos = extras.getIntegerArrayList(SimpleListDialog.SELECTED_POSITIONS);
// ...
return true;
}
return false;
}Make sure to check the demo application.
Copyright 2017 Philipp Niedermayer (github.com/eltos)
Licensed under the Apache License 2.0
You may only use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software in compliance with the License. For more information visit http://www.apache.org/licenses/LICENSE-2.0
The above copyright notice shall be included in all copies or substantial portions of the Software no only in source code but also in a license listing accessible by the user.
I would appreciate if you could send me an email when you release an application that uses this library. Thanks!