Android 12 Developer Preview is here! Try it out, and give us your feedback!

Toggle.Builder

public static final class Toggle.Builder
extends Object

java.lang.Object
   ↳ com.google.android.libraries.car.app.model.Toggle.Builder


A builder of Toggle.

Summary

Public methods

Toggle build()

Constructs the Toggle defined by this builder.

Toggle.Builder setChecked(boolean checked)

Sets the initial checked state for Toggle.

Toggle.Builder setCheckedChangeListener(Toggle.OnCheckedChangeListener onCheckedChangeListener)

Sets the Toggle.OnCheckedChangeListener to call when the checked state of the Toggle is changed.

Inherited methods

Public methods

build

public Toggle build ()

Constructs the Toggle defined by this builder.

Returns
Toggle

setChecked

public Toggle.Builder setChecked (boolean checked)

Sets the initial checked state for Toggle.

The default state of a Toggle is unchecked.

Parameters
checked boolean

Returns
Toggle.Builder

setCheckedChangeListener

public Toggle.Builder setCheckedChangeListener (Toggle.OnCheckedChangeListener onCheckedChangeListener)

Sets the Toggle.OnCheckedChangeListener to call when the checked state of the Toggle is changed.

Parameters
onCheckedChangeListener Toggle.OnCheckedChangeListener

Returns
Toggle.Builder

Throws
NullPointerException if onCheckedChangeListener is null.