public class DropDownPreference extends ListPreference
ListPreference
that presents the options in a
drop down menu rather than a dialog.DialogPreference.TargetFragment
Preference.BaseSavedState, Preference.OnPreferenceChangeListener, Preference.OnPreferenceClickListener
DEFAULT_ORDER
Constructor and Description |
---|
DropDownPreference(Context context) |
DropDownPreference(Context context,
AttributeSet attrs) |
DropDownPreference(Context context,
AttributeSet attrs,
int defStyle) |
DropDownPreference(Context context,
AttributeSet attrs,
int defStyleAttr,
int defStyleRes) |
Modifier and Type | Method and Description |
---|---|
protected ArrayAdapter |
createAdapter()
By default, this class uses a simple
ArrayAdapter . |
int |
findSpinnerIndexOfValue(String value) |
protected void |
notifyChanged()
Should be called when the data of this
Preference has changed. |
void |
onBindViewHolder(PreferenceViewHolder view)
Binds the created View to the data for this Preference.
|
protected void |
onClick()
Processes a click on the preference.
|
void |
setEntries(CharSequence[] entries)
Sets the human-readable entries to be shown in the list.
|
void |
setValueIndex(int index)
Sets the value to the given index from the entry values.
|
findIndexOfValue, getEntries, getEntry, getEntryValues, getSummary, getValue, onGetDefaultValue, onRestoreInstanceState, onSaveInstanceState, onSetInitialValue, setEntries, setEntryValues, setEntryValues, setSummary, setValue
getDialogIcon, getDialogLayoutResource, getDialogMessage, getDialogTitle, getNegativeButtonText, getPositiveButtonText, setDialogIcon, setDialogIcon, setDialogLayoutResource, setDialogMessage, setDialogMessage, setDialogTitle, setDialogTitle, setNegativeButtonText, setNegativeButtonText, setPositiveButtonText, setPositiveButtonText
callChangeListener, compareTo, findPreferenceInHierarchy, getContext, getDependency, getExtras, getFragment, getIcon, getIntent, getKey, getLayoutResource, getOnPreferenceChangeListener, getOnPreferenceClickListener, getOrder, getPersistedBoolean, getPersistedFloat, getPersistedInt, getPersistedLong, getPersistedString, getPreferenceManager, getSharedPreferences, getShouldDisableView, getTitle, getWidgetLayoutResource, hasKey, isEnabled, isPersistent, isSelectable, isVisible, notifyDependencyChange, notifyHierarchyChanged, onAttached, onAttachedToHierarchy, onAttachedToHierarchy, onDependencyChanged, onDetached, onInitializeAccessibilityNodeInfo, onParentChanged, onPrepareForRemoval, peekExtras, performClick, performClick, persistBoolean, persistFloat, persistInt, persistLong, persistString, restoreHierarchyState, saveHierarchyState, setDefaultValue, setDependency, setEnabled, setFragment, setIcon, setIcon, setIntent, setKey, setLayoutResource, setOnPreferenceChangeListener, setOnPreferenceClickListener, setOrder, setPersistent, setSelectable, setShouldDisableView, setSummary, setTitle, setTitle, setViewId, setVisible, setWidgetLayoutResource, shouldDisableDependents, shouldPersist, toString
public DropDownPreference(Context context)
public DropDownPreference(Context context, AttributeSet attrs)
public DropDownPreference(Context context, AttributeSet attrs, int defStyle)
public DropDownPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
protected void onClick()
Preference
SharedPreferences
. However, the overridden method should
call Preference.callChangeListener(Object)
to make sure the client wants to
update the preference's state with the new value.onClick
in class DialogPreference
public void setEntries(@NonNull CharSequence[] entries)
ListPreference
Each entry must have a corresponding index in
ListPreference.setEntryValues(CharSequence[])
.
setEntries
in class ListPreference
entries
- The entries.ListPreference.setEntryValues(CharSequence[])
protected ArrayAdapter createAdapter()
ArrayAdapter
. But if you need
a more complicated ArrayAdapter
, this method can be overridden to
create a custom one.
Note: This method is called from the constructor. So, overridden methods will get called before any subclass initialization.
ArrayAdapter
that needs to be used with this class.public void setValueIndex(int index)
ListPreference
setValueIndex
in class ListPreference
index
- The index of the value to set.public int findSpinnerIndexOfValue(String value)
protected void notifyChanged()
Preference
Preference
has changed.notifyChanged
in class Preference
public void onBindViewHolder(PreferenceViewHolder view)
Preference
This is a good place to grab references to custom Views in the layout and set properties on them.
Make sure to call through to the superclass's implementation.
onBindViewHolder
in class Preference
view
- The ViewHolder that provides references to the views to fill in. These views
will be recycled, so you should not hold a reference to them after this method
returns.