SwitchPreferenceCompat

public class SwitchPreferenceCompat
extends TwoStatePreference

java.lang.Object
   ↳ androidx.preference.Preference
     ↳ androidx.preference.TwoStatePreference
       ↳ androidx.preference.SwitchPreferenceCompat


A Preference that provides a two-state toggleable option.

This preference will save a boolean value to SharedPreferences.

Summary

Inherited constants

Inherited fields

Public constructors

SwitchPreferenceCompat(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Construct a new SwitchPreference with the given style options.

SwitchPreferenceCompat(Context context, AttributeSet attrs, int defStyleAttr)

Construct a new SwitchPreference with the given style options.

SwitchPreferenceCompat(Context context, AttributeSet attrs)

Construct a new SwitchPreference with the given style options.

SwitchPreferenceCompat(Context context)

Construct a new SwitchPreference with default style options.

Public methods

CharSequence getSwitchTextOff()
CharSequence getSwitchTextOn()
void onBindViewHolder(PreferenceViewHolder holder)

Binds the created View to the data for this preference.

void setSwitchTextOff(int resId)

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

void setSwitchTextOff(CharSequence offText)

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

void setSwitchTextOn(CharSequence onText)

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

void setSwitchTextOn(int resId)

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

Inherited methods