-
-
Notifications
You must be signed in to change notification settings - Fork 18
SimpleListDialog
extends CustomListDialog
API reference | Examples |
---|
A ListDialog that displays simple text items. Single choice, direct single choice and multi choice are supported as well as different or custom layout.
For general usage see CustomListDialog which provides choice modes, presets, filter etc.
Items can be provided by using any of
.items(String[] labels)
.items(Context context, @ArrayRes int labelArrayResourceIds)
.items(Context context, int[] labelsResourceIds)
.items(String[] labels, long[] ids)
-
items(ArrayList<? extends SimpleListItem> items)
The optional array of ids can be used to identify which labels were selected inonResult
by id (rather than by index). You can also use a custom set of objects extending SimpleListItem and customize it'sgetString()
and (optionally)getId()
method.
The item layout can be adjusted by using layout(int layout)
.
The following presets are available:
-
LAYOUT_AUTO
(default, an appropriate layout is chosen automatically based on choice mode and preset) LAYOUT_PLAIN
-
LAYOUT_SINGLE_CHOICE
(radio button) -
LAYOUT_MULTI_CHOICE
(check boxes) -
LAYOUT_ACTION
(arrows) When using a custom layout resource, a TextView with idandroid.R.id#text1
is required.
Please refer to the API reference for a comprehensive documentation of these methods.
For general usage see CustomListDialog.
The extras
Bundle returned will contain the following additional keys:
// Only for `SINGLE_CHOICE`- and `SINGLE_CHOICE_DIRECT`-modes:
String label = extras.getString(SimpleListDialog.SELECTED_SINGLE_LABEL);
long id = extras.getLong(SimpleListDialog.SELECTED_SINGLE_ID); // derived from CustomListDialog
// For all modes except `NO_CHOICE`:
ArrayList<String> labels = extras.getStringArrayList(SimpleListDialog.SELECTED_LABELS);
long[] ids = extras.getLongArray(SimpleListDialog.SELECTED_IDS); // derived from CustomListDialog
SimpleListDialog.build()
.title(R.string.select_one)
.items(this, new int[]{R.string.choice_A,
R.string.choice_B,
R.string.choice_C})
.choiceMode(SimpleListDialog.SINGLE_CHOICE)
.choiceIdPreset(R.string.choice_B)
.show(this); |
|
SimpleListDialog.build()
.title(R.string.select_up_to_5)
.choiceMode(SimpleListDialog.MULTI_CHOICE)
.choiceMin(1)
.choiceMax(5)
.items(getBaseContext(), R.array.activites)
.filterable(true)
.show(this, CHOICE_DIALOG); |
|
SimpleListDialog.build()
.title(R.string.select_one)
.choiceMode(SimpleListDialog.SINGLE_CHOICE_DIRECT)
.layout(SimpleListDialog.LAYOUT_ACTION)
.items(getBaseContext(), R.array.settings)
.show(this, CHOICE_DIALOG); |
|
SimpleListDialog.build()
.title(R.string.select_one)
.choiceMode(SimpleListDialog.SINGLE_CHOICE_DIRECT)
.layout(SimpleListDialog.LAYOUT_ACTION)
.items(getBaseContext(), R.array.countries)
.filterable(true, true)
.show(this, CHOICE_DIALOG); |
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