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
Row
s can have asetToggle
set - Each
Row
must conform toROW_CONSTRAINTS_FULL_LIST
Summary
Public constructors |
---|
Builder() Create a new |
Public functions |
|
---|---|
RowSection |
build() Constructs a new |
RowSection.Builder |
Unsets this |
RowSection.Builder |
@CanIgnoreReturnValue Sets this entire |
Inherited functions |
||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Public constructors
Public functions
build
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
@CanIgnoreReturnValue
fun clearSelectionGroup(): RowSection.Builder
Unsets this RowSection
from being shown as a selection group. See setAsSelectionGroup
.
setAsSelectionGroup
@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 |