Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

SeekBarPreference

open class SeekBarPreference : Preference
kotlin.Any
   ↳ androidx.preference.Preference
   ↳ androidx.preference.SeekBarPreference

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

Inherited constants
Public constructors
<init>(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

<init>(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

<init>(context: Context!, attrs: AttributeSet!)

<init>(context: Context!)

Public methods
open Int

Gets the upper bound set on the SeekBar.

open Boolean

Gets whether the current SeekBar value is displayed to the user.

open Unit
setShowSeekBarValue(showSeekBarValue: Boolean)

Sets whether the current SeekBar value is displayed to the user.

Int

Returns the amount of increment change via each arrow key click.

open Unit
setMin(min: Int)

Sets the lower bound on the SeekBar.

open Boolean

Gets whether the SeekBar should respond to the left/right keys.

open Unit
setAdjustable(adjustable: Boolean)

Sets whether the SeekBar should respond to the left/right keys.

open Unit
setUpdatesContinuously(updatesContinuously: Boolean)

Sets whether the SeekBarPreference should continuously save the SeekBar value while it is being dragged.

open Int

Gets the current progress of the SeekBar.

Unit
setSeekBarIncrement(seekBarIncrement: Int)

Sets the increment amount on the SeekBar for each arrow key press.

open Unit

open Unit
setValue(seekBarValue: Int)

Sets the current progress of the SeekBar.

open Boolean

Gets whether the SeekBarPreference should continuously save the SeekBar value while it is being dragged.

Unit
setMax(max: Int)

Sets the upper bound on the SeekBar.

open Int

Gets the lower bound set on the SeekBar.

Protected methods
open Parcelable!

open Unit

open Any!

open Unit
onSetInitialValue(defaultValue: Any?)

Inherited functions

Public constructors

<init>

SeekBarPreference(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

<init>

SeekBarPreference(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

<init>

SeekBarPreference(context: Context!, attrs: AttributeSet!)

<init>

SeekBarPreference(context: Context!)

Public methods

getMax

open fun getMax(): Int

Gets the upper bound set on the SeekBar.

Return
Int: The upper bound set

getShowSeekBarValue

open fun getShowSeekBarValue(): Boolean

Gets whether the current SeekBar value is displayed to the user.

Return
Boolean: Whether the current SeekBar value is displayed to the user

setShowSeekBarValue

open fun setShowSeekBarValue(showSeekBarValue: Boolean): Unit

Sets whether the current SeekBar value is displayed to the user.

Parameters
showSeekBarValue Boolean: Whether the current SeekBar value is displayed to the user

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.

Return
Int: The amount of increment on the SeekBar performed after each user's arrow key press

setMin

open fun setMin(min: Int): Unit

Sets the lower bound on the SeekBar.

Parameters
min Int: The lower bound to set

isAdjustable

open fun isAdjustable(): Boolean

Gets whether the SeekBar should respond to the left/right keys.

Return
Boolean: Whether the SeekBar should respond to the left/right keys

setAdjustable

open fun setAdjustable(adjustable: Boolean): Unit

Sets whether the SeekBar should respond to the left/right keys.

Parameters
adjustable Boolean: Whether the SeekBar should respond to the left/right keys

setUpdatesContinuously

open 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 SeekBarPreference should continuously save the SeekBar value while it is being dragged

getValue

open fun getValue(): Int

Gets the current progress of the SeekBar.

Return
Int: The current progress of the SeekBar

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.

onBindViewHolder

open fun onBindViewHolder(view: PreferenceViewHolder!): Unit

setValue

open fun setValue(seekBarValue: Int): Unit

Sets the current progress of the SeekBar.

Parameters
seekBarValue Int: The current progress of the SeekBar

getUpdatesContinuously

open 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.

Return
Boolean: Whether the SeekBarPreference should continuously save the SeekBar value while it is being dragged

setMax

fun setMax(max: Int): Unit

Sets the upper bound on the SeekBar.

Parameters
max Int: The upper bound to set

getMin

open fun getMin(): Int

Gets the lower bound set on the SeekBar.

Return
Int: The lower bound set

Protected methods

onSaveInstanceState

protected open fun onSaveInstanceState(): Parcelable!

onRestoreInstanceState

protected open fun onRestoreInstanceState(state: Parcelable!): Unit

onGetDefaultValue

protected open fun onGetDefaultValue(a: TypedArray!, index: Int): Any!

onSetInitialValue

protected open fun onSetInitialValue(defaultValue: Any?): Unit