public class SwitchPreference extends AbstractCompoundButtonPreference
AbstractTwoStatePreference.SavedState| Constructor and Description |
|---|
SwitchPreference(android.content.Context context)
Creates a new preference, which provides a two-state toggleable option using a SwitchCompat
widget.
|
SwitchPreference(android.content.Context context,
android.util.AttributeSet attributeSet)
Creates a new preference, which provides a two-state toggleable option using a SwitchCompat
widget.
|
SwitchPreference(android.content.Context context,
android.util.AttributeSet attributeSet,
int defaultStyle)
Creates a new preference, which provides a two-state toggleable option using a SwitchCompat
widget.
|
SwitchPreference(android.content.Context context,
android.util.AttributeSet attributeSet,
int defaultStyle,
int defaultStyleResource)
Creates a new preference, which provides a two-state toggleable option using a SwitchCompat
widget.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.CharSequence |
getSwitchTextOff()
Returns the text, which is displayed on the preference's switch, when it is not checked.
|
java.lang.CharSequence |
getSwitchTextOn()
Returns the text, which is displayed on the preference's switch, when it is checked.
|
void |
onBindViewHolder(PreferenceViewHolder holder) |
void |
setSwitchTextOff(java.lang.CharSequence switchTextOff)
Sets the text, which should be displayed on the preference's switch, when it is not checked.
|
void |
setSwitchTextOff(int resourceId)
Sets the text, which should be displayed on the preference's switch, when it is not checked.
|
void |
setSwitchTextOn(java.lang.CharSequence switchTextOn)
Sets the text, which should be displayed on the preference's switch, when it is checked.
|
void |
setSwitchTextOn(int resourceId)
Sets the text, which should be displayed on the preference's switch, when it is checked.
|
onCheckedChangedgetDisableDependentsState, getSummary, getSummaryOff, getSummaryOn, isChecked, onClick, onGetDefaultValue, onRestoreInstanceState, onSaveInstanceState, onSetInitialValue, performClick, setChecked, setDisableDependentsState, setSummaryOff, setSummaryOff, setSummaryOn, setSummaryOn, shouldDisableDependents, togglegetIconTintList, getIconTintMode, setIcon, setIconTint, setIconTintList, setIconTintModepublic SwitchPreference(android.content.Context context)
context - The context, which should be used by the preference, as an instance of the class
Context. The context may not be nullpublic SwitchPreference(android.content.Context context,
android.util.AttributeSet attributeSet)
context - The context, which should be used by the preference, as an instance of the class
Context. The context may not be nullattributeSet - The attributes of the XML tag that is inflating the preference, as an instance of the
type AttributeSet or null, if no attributes are availablepublic SwitchPreference(android.content.Context context,
android.util.AttributeSet attributeSet,
int defaultStyle)
context - The context, which should be used by the preference, as an instance of the class
Context. The context may not be nullattributeSet - The attributes of the XML tag that is inflating the preference, as an instance of the
type AttributeSet or null, if no attributes are availabledefaultStyle - The default style to apply to this preference. If 0, no style will be applied (beyond
what is included in the theme). This may either be an attribute resource, whose value
will be retrieved from the current theme, or an explicit style resourcepublic SwitchPreference(android.content.Context context,
android.util.AttributeSet attributeSet,
int defaultStyle,
int defaultStyleResource)
context - The context, which should be used by the preference, as an instance of the class
Context. The context may not be nullattributeSet - The attributes of the XML tag that is inflating the preference, as an instance of the
type AttributeSet or null, if no attributes are availabledefaultStyle - The default style to apply to this preference. If 0, no style will be applied (beyond
what is included in the theme). This may either be an attribute resource, whose value
will be retrieved from the current theme, or an explicit style resourcedefaultStyleResource - A resource identifier of a style resource that supplies default values for the
preference, used only if the default style is 0 or can not be found in the theme. Can
be 0 to not look for defaultspublic final java.lang.CharSequence getSwitchTextOn()
CharSequence or null, if no dedicated text is displayed when the
preference's switch is checkedpublic final void setSwitchTextOn(java.lang.CharSequence switchTextOn)
switchTextOn - The text, which should be set, as an instance of the type CharSequence or
null, if no dedicated text should be displayed when the preference's switch is
checkedpublic final void setSwitchTextOn(int resourceId)
resourceId - The resource id of the text, which should be set, as an Integer value. The
resource id must correspond to a valid string resourcepublic final java.lang.CharSequence getSwitchTextOff()
CharSequence or null, if no dedicated text is displayed when
the preference's switch is not checkedpublic final void setSwitchTextOff(java.lang.CharSequence switchTextOff)
switchTextOff - The text, which should be set, as an instance of the type CharSequence or
null, if no dedicated text should be displayed when the preference's switch is not
checkedpublic final void setSwitchTextOff(int resourceId)
resourceId - The resource id of the text, which should be set, as an Integer value. The
resource id must correspond to a valid string resourcepublic void onBindViewHolder(PreferenceViewHolder holder)
onBindViewHolder in class AbstractCompoundButtonPreference