Package eltos.simpledialogfragment.list
Class SimpleListDialog
java.lang.Object
androidx.fragment.app.Fragment
androidx.fragment.app.DialogFragment
eltos.simpledialogfragment.SimpleDialog<This>
eltos.simpledialogfragment.CustomViewDialog<This>
eltos.simpledialogfragment.list.CustomListDialog<SimpleListDialog>
eltos.simpledialogfragment.list.SimpleListDialog
- All Implemented Interfaces:
android.content.ComponentCallbacks
,android.content.DialogInterface.OnCancelListener
,android.content.DialogInterface.OnDismissListener
,android.view.View.OnCreateContextMenuListener
,android.widget.AdapterView.OnItemClickListener
,android.widget.AdapterView.OnItemLongClickListener
,androidx.activity.result.ActivityResultCaller
,androidx.lifecycle.HasDefaultViewModelProviderFactory
,androidx.lifecycle.LifecycleOwner
,androidx.lifecycle.ViewModelStoreOwner
,androidx.savedstate.SavedStateRegistryOwner
A dialog that displays a filterable list in single- or multi-choice mode.
Created by eltos on 02.01.2017.
-
Nested Class Summary
Nested classes/interfaces inherited from class eltos.simpledialogfragment.SimpleDialog
SimpleDialog.OnDialogResultListener
Nested classes/interfaces inherited from class androidx.fragment.app.Fragment
androidx.fragment.app.Fragment.InstantiationException, androidx.fragment.app.Fragment.SavedState
-
Field Summary
Modifier and TypeFieldDescriptionprotected static final String
protected static final String
protected static final String
static final int
static final int
static final int
static final int
static final int
static final String
static final String
static final String
Fields inherited from class eltos.simpledialogfragment.list.CustomListDialog
CHOICE_MAX_COUNT, CHOICE_MIN_COUNT, CHOICE_MODE, INITIALLY_CHECKED_IDS, INITIALLY_CHECKED_POSITIONS, mAdapter, mFilterEditText, mListView, MULTI_CHOICE, NO_CHOICE, SELECTED_IDS, SELECTED_POSITIONS, SELECTED_SINGLE_ID, SELECTED_SINGLE_POSITION, SINGLE_CHOICE, SINGLE_CHOICE_DIRECT
Fields inherited from class eltos.simpledialogfragment.SimpleDialog
BUNDLE, CANCELABLE, FULLSCREEN, HTML, ICON_RESOURCE, MESSAGE, NEGATIVE_BUTTON_TEXT, NEUTRAL_BUTTON_TEXT, POSITIVE_BUTTON_TEXT, THEME, TITLE
Fields inherited from class androidx.fragment.app.DialogFragment
STYLE_NO_FRAME, STYLE_NO_INPUT, STYLE_NO_TITLE, STYLE_NORMAL
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic SimpleListDialog
build()
filterable
(boolean enabled, boolean highlight) If set to true, show an input field at the to of the list and allow the user to filter the listitems
(android.content.Context context, int labelArrayResourceIds) Populate the list using a string array resource iditems
(android.content.Context context, int[] labelsResourceIds) Populate the list with the labels providedPopulate the list with the labels providedPopulate the list with the labels provided The corresponding ids can be used to identify which labels were selecteditems
(ArrayList<SimpleListItem> items) Populate the list with the Items provided.layout
(int layout) Set the item layout to use for the list, one ofLAYOUT_AUTO
,LAYOUT_PLAIN
,LAYOUT_SINGLE_CHOICE
,LAYOUT_MULTI_CHOICE
,LAYOUT_ACTION
or a custom layout resource.protected eltos.simpledialogfragment.list.SimpleListDialog.SimpleListAdapter
Overwrite this method to provide a custom adapterprotected android.os.Bundle
onResult
(int which) Overwrite this method to provide additional results from your custom view to be passed to theSimpleDialog.OnDialogResultListener.onResult(java.lang.String, int, android.os.Bundle)
Methods inherited from class eltos.simpledialogfragment.list.CustomListDialog
choiceIdPreset, choiceIdPreset, choiceIdPreset, choiceMax, choiceMin, choiceMode, choicePreset, choicePreset, choicePreset, divider, emptyText, emptyText, filterable, getListView, grid, gridColumnWidth, gridNumColumn, notifyDataSetChanged, onCreateContentView, onDialogShown, onItemClick, onItemLongClick, onSaveInstanceState, pos, pos, updatePosButton
Methods inherited from class eltos.simpledialogfragment.CustomViewDialog
acceptsPositiveButtonPress, callResultListener, extractContentView, inflate, inflate, onCreate, onCreateDialog, onNegativeButtonClick, onNeutralButtonClick, onPositiveButtonClick, pressPositiveButton, setNegativeButtonEnabled, setNeutralButtonEnabled, setPositiveButtonEnabled
Methods inherited from class eltos.simpledialogfragment.SimpleDialog
cancelable, extra, fullscreen, fullscreen, getArgs, getArgString, getContext, getExtras, getMessage, getTitle, icon, isCancelable, msg, msg, msgHtml, msgHtml, neg, neg, neg, neut, neut, neut, onCancel, onDestroyView, setArg, setArg, setArg, setArg, setButtonClickListener, setButtonEnabled, show, show, show, show, show, show, show, show, showKeyboard, theme, title, title
Methods inherited from class androidx.fragment.app.DialogFragment
dismiss, dismissAllowingStateLoss, getDialog, getShowsDialog, getTheme, onAttach, onDetach, onDismiss, onGetLayoutInflater, onStart, onStop, onViewStateRestored, requireDialog, setCancelable, setShowsDialog, setStyle, setupDialog, showNow
Methods inherited from class androidx.fragment.app.Fragment
dump, equals, getActivity, getAllowEnterTransitionOverlap, getAllowReturnTransitionOverlap, getArguments, getChildFragmentManager, getDefaultViewModelProviderFactory, getEnterTransition, getExitTransition, getFragmentManager, getHost, getId, getLayoutInflater, getLayoutInflater, getLifecycle, getLoaderManager, getParentFragment, getParentFragmentManager, getReenterTransition, getResources, getRetainInstance, getReturnTransition, getSavedStateRegistry, getSharedElementEnterTransition, getSharedElementReturnTransition, getString, getString, getTag, getTargetFragment, getTargetRequestCode, getText, getUserVisibleHint, getView, getViewLifecycleOwner, getViewLifecycleOwnerLiveData, getViewModelStore, hashCode, hasOptionsMenu, instantiate, instantiate, isAdded, isDetached, isHidden, isInLayout, isMenuVisible, isRemoving, isResumed, isStateSaved, isVisible, onActivityCreated, onActivityResult, onAttach, onAttachFragment, onConfigurationChanged, onContextItemSelected, onCreateAnimation, onCreateAnimator, onCreateContextMenu, onCreateOptionsMenu, onCreateView, onDestroy, onDestroyOptionsMenu, onHiddenChanged, onInflate, onInflate, onLowMemory, onMultiWindowModeChanged, onOptionsItemSelected, onOptionsMenuClosed, onPause, onPictureInPictureModeChanged, onPrepareOptionsMenu, onPrimaryNavigationFragmentChanged, onRequestPermissionsResult, onResume, onViewCreated, postponeEnterTransition, postponeEnterTransition, registerForActivityResult, registerForActivityResult, registerForContextMenu, requestPermissions, requireActivity, requireArguments, requireContext, requireFragmentManager, requireHost, requireParentFragment, requireView, setAllowEnterTransitionOverlap, setAllowReturnTransitionOverlap, setArguments, setEnterSharedElementCallback, setEnterTransition, setExitSharedElementCallback, setExitTransition, setHasOptionsMenu, setInitialSavedState, setMenuVisibility, setReenterTransition, setRetainInstance, setReturnTransition, setSharedElementEnterTransition, setSharedElementReturnTransition, setTargetFragment, setUserVisibleHint, shouldShowRequestPermissionRationale, startActivity, startActivity, startActivityForResult, startActivityForResult, startIntentSenderForResult, startPostponedEnterTransition, toString, unregisterForContextMenu
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface androidx.lifecycle.HasDefaultViewModelProviderFactory
getDefaultViewModelCreationExtras
-
Field Details
-
TAG
- See Also:
-
SELECTED_LABELS
- See Also:
-
SELECTED_SINGLE_LABEL
- See Also:
-
LAYOUT_AUTO
@LayoutRes public static final int LAYOUT_AUTO- See Also:
-
LAYOUT_PLAIN
@LayoutRes public static final int LAYOUT_PLAIN -
LAYOUT_SINGLE_CHOICE
@LayoutRes public static final int LAYOUT_SINGLE_CHOICE -
LAYOUT_MULTI_CHOICE
@LayoutRes public static final int LAYOUT_MULTI_CHOICE -
LAYOUT_ACTION
@LayoutRes public static final int LAYOUT_ACTION -
DATA_SET
- See Also:
-
HIGHLIGHT
- See Also:
-
LAYOUT
- See Also:
-
-
Constructor Details
-
SimpleListDialog
public SimpleListDialog()
-
-
Method Details
-
build
-
items
Populate the list with the labels provided- Parameters:
context
- a context for resolving the string ids (cannot use getContext() here)labelsResourceIds
- a list of android string resource identifiers- Returns:
- this instance
-
items
Populate the list using a string array resource id- Parameters:
context
- a context for resolving the resource id (cannot use getContext() here)labelArrayResourceIds
- an android string array resource identifier- Returns:
- this instance
-
items
Populate the list with the labels provided- Parameters:
labels
- a list of string to be displayed- Returns:
- this instance
-
items
Populate the list with the labels provided The corresponding ids can be used to identify which labels were selected- Parameters:
labels
- a list of string to be displayedids
- a list of ids corresponding to the strings- Returns:
- this instance
- Throws:
IllegalArgumentException
- if the arrays length don't match
-
items
Populate the list with the Items provided. SeeSimpleListItem
for further details- Parameters:
items
- a list ofSimpleListItem
- Returns:
- this instance
-
filterable
If set to true, show an input field at the to of the list and allow the user to filter the list- Parameters:
enabled
- whether to allow filtering or nothighlight
- whether to highlight the text filtered- Returns:
- this instance
-
layout
Set the item layout to use for the list, one ofLAYOUT_AUTO
,LAYOUT_PLAIN
,LAYOUT_SINGLE_CHOICE
,LAYOUT_MULTI_CHOICE
,LAYOUT_ACTION
or a custom layout resource. When usingLAYOUT_AUTO
(which is the default), an appropriate item layout will be chosen based on theCustomListDialog.choiceMode(int)
andCustomListDialog.choicePreset(java.util.List<java.lang.Integer>)
orCustomListDialog.choiceIdPreset(java.util.List<java.lang.Long>)
setting When using a custom layout resource, aTextView
with idR.id.text1
is required.- Parameters:
layout
- the layout to use for each item- Returns:
- this instance
-
onCreateAdapter
protected eltos.simpledialogfragment.list.SimpleListDialog.SimpleListAdapter onCreateAdapter()Description copied from class:CustomListDialog
Overwrite this method to provide a custom adapter- Specified by:
onCreateAdapter
in classCustomListDialog<SimpleListDialog>
- Returns:
- the ListAdapter to use
-
onResult
protected android.os.Bundle onResult(int which) Description copied from class:CustomViewDialog
Overwrite this method to provide additional results from your custom view to be passed to theSimpleDialog.OnDialogResultListener.onResult(java.lang.String, int, android.os.Bundle)
- Overrides:
onResult
in classCustomListDialog<SimpleListDialog>
- Parameters:
which
- seeSimpleDialog.OnDialogResultListener
- Returns:
- the bundle to merge with the results or null
-