SeekBarPreference
class SeekBarPreference : Preference
Preference based on android.preference.SeekBarPreference but uses support preference as a base . It contains a title and a SeekBar and an optional SeekBar value TextView. The actual preference layout is customizable by setting android:layout on the preference widget layout or seekBarPreferenceStyle attribute.
The SeekBar within the preference can be defined adjustable or not by setting
adjustable attribute. If adjustable, the preference will be responsive to DPAD left/right keys. Otherwise, it skips those keys.
The SeekBar value view can be shown or disabled by setting showSeekBarValue attribute to true or false, respectively.
Other SeekBar specific attributes (e.g. title, summary, defaultValue, min,
max) can be set directly on the preference widget layout.
Summary
Public constructors |
|---|
SeekBarPreference(context: Context) |
SeekBarPreference(context: Context, attrs: AttributeSet?) |
SeekBarPreference(context: Context, attrs: AttributeSet?, defStyleAttr: Int) |
SeekBarPreference( |
Public functions |
|
|---|---|
Int |
getMax()Gets the upper bound set on the |
Int |
getMin()Gets the lower bound set on the |
Int |
Returns the amount of increment change via each arrow key click. |
Boolean |
Gets whether the current |
Boolean |
Gets whether the |
Int |
getValue()Gets the current progress of the |
Boolean |
Gets whether the |
Unit |
onBindViewHolder(holder: PreferenceViewHolder)Binds the created View to the data for this preference. |
Unit |
setAdjustable(adjustable: Boolean)Sets whether the |
Unit |
Sets the upper bound on the |
Unit |
Sets the lower bound on the |
Unit |
setSeekBarIncrement(seekBarIncrement: Int)Sets the increment amount on the |
Unit |
setShowSeekBarValue(showSeekBarValue: Boolean)Sets whether the current |
Unit |
setUpdatesContinuously(updatesContinuously: Boolean)Sets whether the |
Unit |
Sets the current progress of the |
Protected functions |
|
|---|---|
Any? |
onGetDefaultValue(a: TypedArray, index: Int)Called when a preference is being inflated and the default value attribute needs to be read. |
Unit |
onRestoreInstanceState(state: Parcelable?)Hook allowing a preference to re-apply a representation of its internal state that had previously been generated by |
Parcelable? |
Hook allowing a preference to generate a representation of its internal state that can later be used to create a new instance with that same state. |
Unit |
onSetInitialValue(defaultValue: Any!)Implement this to set the initial value of the preference. |
Inherited Constants |
||
|---|---|---|
|
Inherited functions |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
SeekBarPreference
SeekBarPreference(context: Context, attrs: AttributeSet?, defStyleAttr: Int)
SeekBarPreference
SeekBarPreference(
context: Context,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
)
Public functions
getMax
fun getMax(): Int
Gets the upper bound set on the SeekBar.
| Returns | |
|---|---|
Int |
The upper bound set |
getMin
fun getMin(): Int
Gets the lower bound set on the SeekBar.
| Returns | |
|---|---|
Int |
The lower bound set |
getSeekBarIncrement
fun getSeekBarIncrement(): Int
Returns the amount of increment change via each arrow key click. This value is derived from user's specified increment value if it's not zero. Otherwise, the default value is picked from the default mKeyProgressIncrement value in android.widget.AbsSeekBar.
getShowSeekBarValue
fun getShowSeekBarValue(): Boolean
Gets whether the current SeekBar value is displayed to the user.
| See also | |
|---|---|
setShowSeekBarValue |
getUpdatesContinuously
fun getUpdatesContinuously(): Boolean
Gets whether the SeekBarPreference should continuously save the SeekBar value while it is being dragged. Note that when the value is true, Preference.OnPreferenceChangeListener will be called continuously as well.
| Returns | |
|---|---|
Boolean |
Whether the |
| See also | |
|---|---|
setUpdatesContinuously |
isAdjustable
fun isAdjustable(): Boolean
Gets whether the SeekBar should respond to the left/right keys.
onBindViewHolder
fun onBindViewHolder(holder: PreferenceViewHolder): Unit
Binds the created View to the data for this 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.
| Parameters | |
|---|---|
holder: PreferenceViewHolder |
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. |
setAdjustable
fun setAdjustable(adjustable: Boolean): Unit
Sets whether the SeekBar should respond to the left/right keys.
setMax
fun setMax(max: Int): Unit
Sets the upper bound on the SeekBar.
| Parameters | |
|---|---|
max: Int |
The upper bound to set |
setMin
fun setMin(min: Int): Unit
Sets the lower bound on the SeekBar.
| Parameters | |
|---|---|
min: Int |
The lower bound to set |
setSeekBarIncrement
fun setSeekBarIncrement(seekBarIncrement: Int): Unit
Sets the increment amount on the SeekBar for each arrow key press.
| Parameters | |
|---|---|
seekBarIncrement: Int |
The amount to increment or decrement when the user presses an arrow key. |
setShowSeekBarValue
fun setShowSeekBarValue(showSeekBarValue: Boolean): Unit
Sets whether the current SeekBar value is displayed to the user.
| See also | |
|---|---|
getShowSeekBarValue |
setUpdatesContinuously
fun setUpdatesContinuously(updatesContinuously: Boolean): Unit
Sets whether the SeekBarPreference should continuously save the SeekBar value while it is being dragged.
| Parameters | |
|---|---|
updatesContinuously: Boolean |
Whether the |
| See also | |
|---|---|
getUpdatesContinuously |
Protected functions
onGetDefaultValue
protected fun onGetDefaultValue(a: TypedArray, index: Int): Any?
Called when a preference is being inflated and the default value attribute needs to be read. Since different preference types have different value types, the subclass should get and return the default value which will be its value type.
For example, if the value type is String, the body of the method would proxy to getString.
| Parameters | |
|---|---|
a: TypedArray |
The set of attributes |
index: Int |
The index of the default value attribute |
| Returns | |
|---|---|
Any? |
The default value of this preference type |
onRestoreInstanceState
protected fun onRestoreInstanceState(state: Parcelable?): Unit
Hook allowing a preference to re-apply a representation of its internal state that had previously been generated by onSaveInstanceState. This function will never be called with a null state.
| Parameters | |
|---|---|
state: Parcelable? |
The saved state that had previously been returned by |
| See also | |
|---|---|
onSaveInstanceState |
|
restoreHierarchyState |
onSaveInstanceState
protected fun onSaveInstanceState(): Parcelable?
Hook allowing a preference to generate a representation of its internal state that can later be used to create a new instance with that same state. This state should only contain information that is not persistent or can be reconstructed later.
| Returns | |
|---|---|
Parcelable? |
A Parcelable object containing the current dynamic state of this preference, or |
| See also | |
|---|---|
onRestoreInstanceState |
|
saveHierarchyState |
onSetInitialValue
protected fun onSetInitialValue(defaultValue: Any!): Unit
Implement this to set the initial value of the preference.
If you are persisting values to SharedPreferences or a PreferenceDataStore you should restore the saved value for the preference.
If you are not persisting values, or there is no value saved for the preference, you should set the value of the preference to defaultValue.
| Parameters | |
|---|---|
defaultValue: Any! |
The default value for the preference if set, otherwise |