SwitchPreference

open class SwitchPreference : TwoStatePreference
kotlin.Any
   ↳ androidx.preference.Preference
   ↳ androidx.preference.TwoStatePreference
   ↳ androidx.preference.SwitchPreference

A Preference that provides a two-state toggleable option.

This preference will save a boolean value to android.content.SharedPreferences.

Summary

Inherited constants

Public constructors

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

Construct a new SwitchPreference with the given style options.

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

Construct a new SwitchPreference with the given style options.

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

Construct a new SwitchPreference with the given style options.

<init>(context: Context!)

Construct a new SwitchPreference with default style options.

Public methods

open CharSequence!

open CharSequence!

open Unit

open Unit

Set the text displayed on the switch widget in the off state.

open Unit

Set the text displayed on the switch widget in the off state.

open Unit

Set the text displayed on the switch widget in the on state.

open Unit

Set the text displayed on the switch widget in the on state.

Inherited functions

Inherited properties

Public constructors

<init>

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

Construct a new SwitchPreference with the given style options.

Parameters
context Context!: The Context that will style this preference
attrs Context!: Style attributes that differ from the default
defStyleAttr Context!: An attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults.
defStyleRes Context!: A resource identifier of a style resource that supplies default values for the view, used only if defStyleAttr is 0 or can not be found in the theme. Can be 0 to not look for defaults.

<init>

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

Construct a new SwitchPreference with the given style options.

Parameters
context Context!: The Context that will style this preference
attrs Context!: Style attributes that differ from the default
defStyleAttr Context!: An attribute in the current theme that contains a reference to a style resource that supplies default values for the view. Can be 0 to not look for defaults.

<init>

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

Construct a new SwitchPreference with the given style options.

Parameters
context Context!: The Context that will style this preference
attrs Context!: Style attributes that differ from the default

<init>

SwitchPreference(context: Context!)

Construct a new SwitchPreference with default style options.

Parameters
context Context!: The Context that will style this preference

Public methods

getSwitchTextOff

open fun getSwitchTextOff(): CharSequence!
Return
CharSequence!: The text that will be displayed on the switch widget in the off state

getSwitchTextOn

open fun getSwitchTextOn(): CharSequence!
Return
CharSequence!: The text that will be displayed on the switch widget in the on state

onBindViewHolder

open fun onBindViewHolder(holder: PreferenceViewHolder!): Unit

setSwitchTextOff

open fun setSwitchTextOff(offText: CharSequence!): Unit

Set the text displayed on the switch widget in the off state. This should be a very short string, one word if possible.

Parameters
offText CharSequence!: Text to display in the off state

setSwitchTextOff

open fun setSwitchTextOff(resId: Int): Unit

Set the text displayed on the switch widget in the off state. This should be a very short string, one word if possible.

Parameters
resId Int: The text as a string resource ID

setSwitchTextOn

open fun setSwitchTextOn(onText: CharSequence!): Unit

Set the text displayed on the switch widget in the on state. This should be a very short string, one word if possible.

Parameters
onText CharSequence!: Text to display in the on state

setSwitchTextOn

open fun setSwitchTextOn(resId: Int): Unit

Set the text displayed on the switch widget in the on state. This should be a very short string, one word if possible.

Parameters
resId Int: The text as a string resource ID