Toggle.Builder


class Toggle.Builder


A builder of Toggle.

Summary

Public constructors

Builder(onCheckedChangeListener: Toggle.OnCheckedChangeListener)

Returns a new instance of a Builder with the given OnCheckedChangeListener.

Public functions

Toggle

Constructs the Toggle defined by this builder.

Toggle.Builder
setChecked(checked: Boolean)

Sets the initial checked state for Toggle.

Toggle.Builder
@RequiresCarApi(value = 5)
setEnabled(enabled: Boolean)

Sets the initial enabled state for Toggle.

Public constructors

Builder

Added in 1.0.0
Builder(onCheckedChangeListener: Toggle.OnCheckedChangeListener)

Returns a new instance of a Builder with the given OnCheckedChangeListener.

Note that the listener relates to UI events and will be executed on the main thread using getMainLooper.

Throws
java.lang.NullPointerException

if onCheckedChangeListener is null

Public functions

build

Added in 1.0.0
fun build(): Toggle

Constructs the Toggle defined by this builder.

setChecked

Added in 1.0.0
fun setChecked(checked: Boolean): Toggle.Builder

Sets the initial checked state for Toggle.

The default state of a Toggle is unchecked.

setEnabled

Added in 1.3.0
@RequiresCarApi(value = 5)
fun setEnabled(enabled: Boolean): Toggle.Builder

Sets the initial enabled state for Toggle.

The default state of a Toggle is enabled.