android-components / mozilla.components.browser.menu.item / BrowserMenuItemToolbar / TwoStateButton

TwoStateButton

class TwoStateButton : Button (source)

A button that either shows an primary state or an secondary state based on the provided isInPrimaryState lambda.

Parameters

primaryImageResource - ID of a drawable resource to be shown as primary icon.

primaryContentDescription - The button’s primary content description, used for accessibility support.

primaryImageTintResource - Optional ID of color resource to tint the primary icon.

secondaryImageResource - Optional ID of a different drawable resource to be shown as secondary icon.

secondaryContentDescription - Optional secondary content description for button, for accessibility support.

secondaryImageTintResource - Optional ID of secondary color resource to tint the icon.

isInPrimaryState - Lambda to return true/false to indicate if this button should be primary or secondary.

disableInSecondaryState - Optional boolean to disable the button when in secondary state.

listener - Callback to be invoked when the button is pressed.

Constructors

Name Summary
<init> TwoStateButton(primaryImageResource: Int, primaryContentDescription: String, primaryImageTintResource: Int = NO_ID, secondaryImageResource: Int = primaryImageResource, secondaryContentDescription: String = primaryContentDescription, secondaryImageTintResource: Int = primaryImageTintResource, isInPrimaryState: () -> Boolean = { true }, disableInSecondaryState: Boolean = false, listener: () -> Unit)
A button that either shows an primary state or an secondary state based on the provided isInPrimaryState lambda.

Properties

Name Summary
disableInSecondaryState val disableInSecondaryState: Boolean
Optional boolean to disable the button when in secondary state.
isInPrimaryState val isInPrimaryState: () -> Boolean
Lambda to return true/false to indicate if this button should be primary or secondary.
primaryContentDescription val primaryContentDescription: String
The button’s primary content description, used for accessibility support.
primaryImageResource val primaryImageResource: Int
ID of a drawable resource to be shown as primary icon.
primaryImageTintResource val primaryImageTintResource: Int
Optional ID of color resource to tint the primary icon.
secondaryContentDescription val secondaryContentDescription: String
Optional secondary content description for button, for accessibility support.
secondaryImageResource val secondaryImageResource: Int
Optional ID of a different drawable resource to be shown as secondary icon.
secondaryImageTintResource val secondaryImageTintResource: Int
Optional ID of secondary color resource to tint the icon.

Inherited Properties

Name Summary
contentDescription val contentDescription: String
The button’s content description, used for accessibility support.
iconTintColorResource val iconTintColorResource: Int
Optional ID of color resource to tint the icon.
imageResource val imageResource: Int
ID of a drawable resource to be shown as icon.
isEnabled val isEnabled: () -> Boolean
Lambda to return true/false to indicate if this button should be enabled or disabled.
listener val listener: () -> Unit
Callback to be invoked when the button is pressed.