RowSection.Builder
@ExperimentalCarApi
public final class RowSection.Builder extends Section.BaseBuilder
| java.lang.Object | ||
| ↳ | androidx.car.app.model.Section.BaseBuilder | |
| ↳ | androidx.car.app.model.RowSection.Builder |
A builder that constructs RowSection instances.
Upon building, this class validates the following:
- If this section is set as a selection group, the given
initialSelectedIndexcannot 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 asetToggleset - Each
Rowmust conform toROW_CONSTRAINTS_FULL_LIST
Summary
Public constructors |
|---|
Builder()Create a new |
Public methods |
|
|---|---|
@NonNull RowSection |
build()Constructs a new |
@NonNull RowSection.Builder |
Unsets this |
@NonNull RowSection.Builder |
@CanIgnoreReturnValueSets this entire |
Inherited methods |
||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
Public methods
build
public @NonNull RowSection build()
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
@CanIgnoreReturnValue
public @NonNull RowSection.Builder clearSelectionGroup()
Unsets this RowSection from being shown as a selection group. See setAsSelectionGroup.
setAsSelectionGroup
@CanIgnoreReturnValue
public @NonNull RowSection.Builder setAsSelectionGroup(int initialSelectedIndex)
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 | |
|---|---|
int initialSelectedIndex |
the index of the item to be selected when the template is first rendered |