RowSection.Builder


@ExperimentalCarApi
class RowSection.Builder : Section.BaseBuilder


A builder that constructs RowSection instances.

Upon building, this class validates the following:

  • If this section is set as a selection group, the given initialSelectedIndex cannot be greater than the size of the list (unless the list is empty, in which case this value is ignored)
  • If this section is set as a selection group, none of the added Rows can have a setToggle set
  • Each Row must conform to ROW_CONSTRAINTS_FULL_LIST

Summary

Public constructors

Create a new RowSection builder.

Public functions

RowSection

Constructs a new RowSection from the current state of this builder, throwing exceptions for any invalid state.

RowSection.Builder

Unsets this RowSection from being shown as a selection group.

RowSection.Builder

Sets this entire RowSection as a selection group when passed a non-negative integer correlating to a valid index within the list of items added.

Inherited functions

From androidx.car.app.model.Section.BaseBuilder
B

Adds an item to this section, appending to the existing list of items.

B

Delete all items in this section.

B

Sets the items for this section, overwriting any other previously set items.

B

Sets or clears the optional message to display in this section when there are 0 items added to it.

B

Sets or clears the optional message to display in this section when there are 0 items added to it.

B

Sets or clears the optional title that appears above the items in this section.

B

Sets or clears the optional title that appears above the items in this section.

Public constructors

Builder

Added in 1.7.0-beta03
Builder()

Create a new RowSection builder.

Public functions

build

Added in 1.7.0-beta03
fun build(): RowSection

Constructs a new RowSection from the current state of this builder, throwing exceptions for any invalid state.

See also
RowSection.Builder

for the list of validation logic

clearSelectionGroup

Added in 1.7.0-beta03
@CanIgnoreReturnValue
fun clearSelectionGroup(): RowSection.Builder

Unsets this RowSection from being shown as a selection group. See setAsSelectionGroup.

setAsSelectionGroup

Added in 1.7.0-beta03
@CanIgnoreReturnValue
fun setAsSelectionGroup(initialSelectedIndex: Int): RowSection.Builder

Sets this entire RowSection as a selection group when passed a non-negative integer correlating to a valid index within the list of items added. The UI behaves equivalently to a radio button group where a single item is called out (either by an actual radio button, or through some other highlighting). The host will initially highlight the initialSelectedIndex's item and automatically update the highlight to other items if selected by the user. The app should handle user selections via setOnClickListener.

This cannot be used in conjunction with setToggle.

Parameters
initialSelectedIndex: Int

the index of the item to be selected when the template is first rendered