android-components / mozilla.components.browser.toolbar / BrowserToolbar / ToggleButton

ToggleButton

class ToggleButton : ActionToggleButton (source)

An action button with two states, selected and unselected. When the button is pressed, the state changes automatically.

Parameters

image - The drawable to be shown if the button is in unselected state.

imageSelected - The drawable to be shown if the button is in selected state.

contentDescription - The content description to use if the button is in unselected state.

contentDescriptionSelected - The content description to use if the button is in selected state.

visible - Lambda that returns true or false to indicate whether this button should be shown.

selected - Sets whether this button should be selected initially.

background - A custom (stateful) background drawable resource to be used.

padding - a custom Padding for this Button.

listener - Callback that will be invoked whenever the checked state changes.

Constructors

<init>

ToggleButton(image: Drawable, imageSelected: Drawable, contentDescription: String, contentDescriptionSelected: String, visible: () -> Boolean = { true }, selected: Boolean = false, background: Int = 0, padding: Padding = DEFAULT_PADDING, listener: (Boolean) -> Unit)

An action button with two states, selected and unselected. When the button is pressed, the state changes automatically.

Properties

padding

val padding: Padding

a custom Padding for this Button.

Inherited Properties

visible

open val visible: () -> Boolean

Lambda that returns true or false to indicate whether this button should be shown.

Inherited Functions

bind

open fun bind(view: View): Unit

createView

open fun createView(parent: ViewGroup): View

isSelected

fun isSelected(): Boolean

Returns the current selected state of the action.

setSelected

fun setSelected(selected: Boolean, notifyListener: Boolean = true): Unit

Changes the selected state of the action.

toggle

fun toggle(notifyListener: Boolean = true): Unit

Changes the selected state of the action to the inverse of its current state.