Toggle.Builder


public final class Toggle.Builder


A builder of Toggle.

Summary

Public constructors

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

Public methods

@NonNull Toggle

Constructs the Toggle defined by this builder.

@NonNull Toggle.Builder
setChecked(boolean checked)

Sets the initial checked state for Toggle.

@NonNull Toggle.Builder
@RequiresCarApi(value = 5)
setEnabled(boolean enabled)

Sets the initial enabled state for Toggle.

Public constructors

Builder

Added in 1.0.0
public Builder(@NonNull Toggle.OnCheckedChangeListener 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 methods

build

Added in 1.0.0
public @NonNull Toggle build()

Constructs the Toggle defined by this builder.

setChecked

Added in 1.0.0
public @NonNull Toggle.Builder setChecked(boolean checked)

Sets the initial checked state for Toggle.

The default state of a Toggle is unchecked.

setEnabled

Added in 1.3.0
@RequiresCarApi(value = 5)
public @NonNull Toggle.Builder setEnabled(boolean enabled)

Sets the initial enabled state for Toggle.

The default state of a Toggle is enabled.