public class SettingSpinnerPreference extends SettingPreference
SettingPreference implementation that provides Spinner widget with its related
functionality. Entries that should be available for selection as drop down items of the Spinner
widget may be specified via setEntries(CharSequence[]) along with theirs corresponding
entry values that should be specified via setEntryValues(String[]).
This preference implementation by default displays a single Spinner widget with a primary
view containing title text of the preference and summary text which corresponds to the current
selected entry value. The preferred entry value may be specified via setValue(String) and
obtained via getValue().
String which should contain a single entry
value that should be by default selected. See TypedArray.getString(int).
SettingPreference,
SettingSpinnerPreference Attributes
settingSpinnerPreferenceStyleandroidx.preference.Preference.BaseSavedState, androidx.preference.Preference.OnPreferenceChangeListener, androidx.preference.Preference.OnPreferenceClickListener, androidx.preference.Preference.SummaryProvider<T extends androidx.preference.Preference>| Constructor and Description |
|---|
SettingSpinnerPreference(android.content.Context context)
Same as
SettingSpinnerPreference(Context, AttributeSet) without attributes. |
SettingSpinnerPreference(android.content.Context context,
android.util.AttributeSet attrs)
Same as
SettingSpinnerPreference(Context, AttributeSet, int) with
R.attr.settingSpinnerPreferenceStyle as attribute for default style. |
SettingSpinnerPreference(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr)
Same as
SettingSpinnerPreference(Context, AttributeSet, int, int) with 0
as default style. |
SettingSpinnerPreference(android.content.Context context,
android.util.AttributeSet attrs,
int defStyleAttr,
int defStyleRes)
Creates a new instance of SettingSpinnerPreference for the given context.
|
| Modifier and Type | Method and Description |
|---|---|
CharSequence[] |
getEntries()
Returns the array of entries specified for this preference.
|
String[] |
getEntryValues()
Returns the array of entry values associated with the entries specified for this preference.
|
String |
getValue()
Returns the preferred entry value of this preference.
|
void |
onBindViewHolder(androidx.preference.PreferenceViewHolder holder) |
protected void |
onClick() |
protected Object |
onGetDefaultValue(android.content.res.TypedArray attributes,
int index) |
protected void |
onPrepareForRemoval() |
protected void |
onSetInitialValue(Object defaultValue) |
void |
setEntries(CharSequence[] entries)
Specifies an array of entries that should be displayed in the
Spinner widget of
this preference. |
void |
setEntries(int resId)
Same as
setEntries(CharSequence[]) for resource id. |
void |
setEntryValues(int resId)
Same as
setEntryValues(String[]) for resource id. |
void |
setEntryValues(String[] entryValues)
Specifies an array of entry values where each value should be associated with corresponding
entry from the entries array specified via
setEntries(CharSequence[]). |
void |
setTitle(CharSequence title) |
void |
setValue(String value)
Sets a preferred entry value for this preference.
|
setKeycallChangeListener, compareTo, findPreferenceInHierarchy, getContext, getDependency, getExtras, getFragment, getIcon, getIntent, getKey, getLayoutResource, getOnPreferenceChangeListener, getOnPreferenceClickListener, getOrder, getParent, getPersistedBoolean, getPersistedFloat, getPersistedInt, getPersistedLong, getPersistedString, getPersistedStringSet, getPreferenceDataStore, getPreferenceManager, getSharedPreferences, getShouldDisableView, getSummary, getSummaryProvider, getTitle, getWidgetLayoutResource, hasKey, isCopyingEnabled, isEnabled, isIconSpaceReserved, isPersistent, isSelectable, isShown, isSingleLineTitle, isVisible, notifyChanged, notifyDependencyChange, notifyHierarchyChanged, onAttached, onAttachedToHierarchy, onAttachedToHierarchy, onDependencyChanged, onDetached, onInitializeAccessibilityNodeInfo, onParentChanged, onRestoreInstanceState, onSaveInstanceState, onSetInitialValue, peekExtras, performClick, performClick, persistBoolean, persistFloat, persistInt, persistLong, persistString, persistStringSet, restoreHierarchyState, saveHierarchyState, setCopyingEnabled, setDefaultValue, setDependency, setEnabled, setFragment, setIcon, setIcon, setIconSpaceReserved, setIntent, setLayoutResource, setOnPreferenceChangeListener, setOnPreferenceClickListener, setOrder, setPersistent, setPreferenceDataStore, setSelectable, setShouldDisableView, setSingleLineTitle, setSummary, setSummary, setSummaryProvider, setTitle, setViewId, setVisible, setWidgetLayoutResource, shouldDisableDependents, shouldPersist, toStringpublic SettingSpinnerPreference(@NonNull
android.content.Context context)
SettingSpinnerPreference(Context, AttributeSet) without attributes.public SettingSpinnerPreference(@NonNull
android.content.Context context,
@Nullable
android.util.AttributeSet attrs)
SettingSpinnerPreference(Context, AttributeSet, int) with
R.attr.settingSpinnerPreferenceStyle as attribute for default style.public SettingSpinnerPreference(@NonNull
android.content.Context context,
@Nullable
android.util.AttributeSet attrs,
@AttrRes
int defStyleAttr)
SettingSpinnerPreference(Context, AttributeSet, int, int) with 0
as default style.public SettingSpinnerPreference(@NonNull
android.content.Context context,
@Nullable
android.util.AttributeSet attrs,
@AttrRes
int defStyleAttr,
@StyleRes
int defStyleRes)
context - Context in which will be the new setting preference presented.attrs - Set of Xml attributes used to configure the new instance of this preference.defStyleAttr - An attribute which contains a reference to a default style resource for
this preference within a theme of the given context.defStyleRes - Resource id of the default style for the new preference.protected Object onGetDefaultValue(@NonNull android.content.res.TypedArray attributes, int index)
onGetDefaultValue in class androidx.preference.Preferenceprotected void onSetInitialValue(@Nullable
Object defaultValue)
onSetInitialValue in class androidx.preference.Preferencepublic void setTitle(@Nullable
CharSequence title)
setTitle in class androidx.preference.Preferencepublic void setEntries(@ArrayRes
int resId)
setEntries(CharSequence[]) for resource id.resId - Resource id of the desired text array with entries.public void setEntries(@Nullable
CharSequence[] entries)
Spinner widget of
this preference.entries - The desired array of entries. May be null to clear the current ones.R.attr.entries,
setEntryValues(String[])@Nullable public CharSequence[] getEntries()
null if no entries have been specified.setEntries(CharSequence[]),
getEntryValues()public void setEntryValues(@ArrayRes
int resId)
setEntryValues(String[]) for resource id.resId - Resource id of the desired text array with values for entries.public void setEntryValues(@Nullable
String[] entryValues)
setEntries(CharSequence[]).
Note, that this method does not check if the entries and entry values arrays are consistent, that is that they are equal in length.
entryValues - The desired array of values associated with entries. May be null
to clear the current ones.R.attr.entryValues@Nullable public String[] getEntryValues()
null if no entry values have been specified.setEntryValues(String[]),
getEntries()public void setValue(@Nullable
String value)
If value of this preference changes, it is persisted and the change listener is notified about the change.
value - The preferred entry value to be persisted.getValue()@Nullable public String getValue()
setValue(String)public void onBindViewHolder(@NonNull
androidx.preference.PreferenceViewHolder holder)
onBindViewHolder in class SettingPreferenceprotected void onClick()
onClick in class androidx.preference.Preferenceprotected void onPrepareForRemoval()
onPrepareForRemoval in class androidx.preference.Preference