SeekBarPreference
public
class
SeekBarPreference
extends Preference
java.lang.Object | ||
↳ | 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 | |
---|---|
SeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
|
|
SeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr)
|
|
SeekBarPreference(Context context, AttributeSet attrs)
|
|
SeekBarPreference(Context context)
|
Public methods | |
---|---|
int
|
getMax()
Gets the upper bound set on the |
int
|
getMin()
Gets the lower bound set on the |
final
int
|
getSeekBarIncrement()
Returns the amount of increment change via each arrow key click. |
boolean
|
getShowSeekBarValue()
Gets whether the current |
boolean
|
getUpdatesContinuously()
Gets whether the |
int
|
getValue()
Gets the current progress of the |
boolean
|
isAdjustable()
Gets whether the |
void
|
onBindViewHolder(PreferenceViewHolder view)
Binds the created View to the data for this preference. |
void
|
setAdjustable(boolean adjustable)
Sets whether the |
final
void
|
setMax(int max)
Sets the upper bound on the |
void
|
setMin(int min)
Sets the lower bound on the |
final
void
|
setSeekBarIncrement(int seekBarIncrement)
Sets the increment amount on the |
void
|
setShowSeekBarValue(boolean showSeekBarValue)
Sets whether the current |
void
|
setUpdatesContinuously(boolean updatesContinuously)
Sets whether the |
void
|
setValue(int seekBarValue)
Sets the current progress of the |
Protected methods | |
---|---|
Object
|
onGetDefaultValue(TypedArray a, int index)
Called when a preference is being inflated and the default value attribute needs to be read. |
void
|
onRestoreInstanceState(Parcelable state)
Hook allowing a preference to re-apply a representation of its internal state that had
previously been generated by |
Parcelable
|
onSaveInstanceState()
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. |
void
|
onSetInitialValue(Object defaultValue)
Implement this to set the initial value of the preference. |
Inherited methods | |
---|---|
Public constructors
SeekBarPreference
public SeekBarPreference (Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)
Parameters | |
---|---|
context |
Context |
attrs |
AttributeSet |
defStyleAttr |
int |
defStyleRes |
int |
SeekBarPreference
public SeekBarPreference (Context context, AttributeSet attrs, int defStyleAttr)
Parameters | |
---|---|
context |
Context |
attrs |
AttributeSet |
defStyleAttr |
int |
SeekBarPreference
public SeekBarPreference (Context context, AttributeSet attrs)
Parameters | |
---|---|
context |
Context |
attrs |
AttributeSet |
Public methods
getMax
public int getMax ()
Gets the upper bound set on the SeekBar
.
Returns | |
---|---|
int |
The upper bound set |
getMin
public int getMin ()
Gets the lower bound set on the SeekBar
.
Returns | |
---|---|
int |
The lower bound set |
getSeekBarIncrement
public final int getSeekBarIncrement ()
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 AbsSeekBar
.
Returns | |
---|---|
int |
The amount of increment on the SeekBar performed after each user's arrow
key press
|
getShowSeekBarValue
public boolean getShowSeekBarValue ()
Gets whether the current SeekBar
value is displayed to the user.
Returns | |
---|---|
boolean |
Whether the current SeekBar value is displayed to the user |
See also:
getUpdatesContinuously
public boolean getUpdatesContinuously ()
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 SeekBarPreference should continuously save the SeekBar
value while it is being dragged |
See also:
getValue
public int getValue ()
Gets the current progress of the SeekBar
.
Returns | |
---|---|
int |
The current progress of the SeekBar
|
isAdjustable
public boolean isAdjustable ()
Gets whether the SeekBar
should respond to the left/right keys.
Returns | |
---|---|
boolean |
Whether the SeekBar should respond to the left/right keys
|
onBindViewHolder
public void onBindViewHolder (PreferenceViewHolder view)
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 | |
---|---|
view |
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
public void setAdjustable (boolean adjustable)
Sets whether the SeekBar
should respond to the left/right keys.
Parameters | |
---|---|
adjustable |
boolean : Whether the SeekBar should respond to the left/right keys
|
setMax
public final void setMax (int max)
Sets the upper bound on the SeekBar
.
Parameters | |
---|---|
max |
int : The upper bound to set
|
setMin
public void setMin (int min)
Sets the lower bound on the SeekBar
.
Parameters | |
---|---|
min |
int : The lower bound to set
|
setSeekBarIncrement
public final void setSeekBarIncrement (int seekBarIncrement)
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
public void setShowSeekBarValue (boolean showSeekBarValue)
Sets whether the current SeekBar
value is displayed to the user.
Parameters | |
---|---|
showSeekBarValue |
boolean : Whether the current SeekBar value is displayed to the user |
See also:
setUpdatesContinuously
public void setUpdatesContinuously (boolean updatesContinuously)
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 |
See also:
setValue
public void setValue (int seekBarValue)
Sets the current progress of the SeekBar
.
Parameters | |
---|---|
seekBarValue |
int : The current progress of the SeekBar
|
Protected methods
onGetDefaultValue
protected Object onGetDefaultValue (TypedArray a, int index)
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
TypedArray.getString(int)
.
Parameters | |
---|---|
a |
TypedArray : The set of attributes |
index |
int : The index of the default value attribute |
Returns | |
---|---|
Object |
The default value of this preference type |
onRestoreInstanceState
protected void onRestoreInstanceState (Parcelable state)
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
onSaveInstanceState() . |
onSaveInstanceState
protected Parcelable onSaveInstanceState ()
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
null if there is nothing interesting to save. The default implementation returns
null . |
onSetInitialValue
protected void onSetInitialValue (Object defaultValue)
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 |
Object : The default value for the preference if set, otherwise null .
|