Added in API level 1

ToggleButton


open class ToggleButton : CompoundButton
kotlin.Any
   ↳ android.view.View
   ↳ android.widget.TextView
   ↳ android.widget.Button
   ↳ android.widget.CompoundButton
   ↳ android.widget.ToggleButton

Displays checked/unchecked states as a button with a "light" indicator and by default accompanied with the text "ON" or "OFF".

See the Toggle Buttons guide.

Summary

XML attributes
android:disabledAlpha The alpha to apply to the indicator when disabled.
android:textOff The text for the button when it is not checked.
android:textOn The text for the button when it is checked.
Inherited XML attributes
Inherited constants
Public constructors
ToggleButton(context: Context!)

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

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

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

Public methods
open CharSequence!

Return the class name of this object to be used for accessibility purposes.

open Float

Returns the alpha value of the button when it is disabled

open CharSequence!

Returns the text for when the button is not in the checked state.

open CharSequence!

Returns the text for when the button is in the checked state.

open Unit

open Unit
setChecked(checked: Boolean)

Changes the checked state of this button.

open Unit

Sets the text for when the button is not in the checked state.

open Unit

Sets the text for when the button is in the checked state.

Protected methods
open Unit

This function is called whenever the state of the view changes in such a way that it impacts the state of drawables being shown.

open Unit

Finalize inflating a view from XML.

Inherited functions