# Section.BaseBuilder

Artifact: [androidx.car.app:app](https://developer.android.com/jetpack/androidx/releases/car-app) [View Source](https://cs.android.com/search?q=file:androidx/car/app/model/Section.java+class:androidx.car.app.model.Section.BaseBuilder) Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

*** ** * ** ***


```
protected abstract class Section.BaseBuilder<T extends Item, B>
```

<br />

Known direct subclasses [BannerSection.Builder](https://developer.android.com/reference/androidx/car/app/model/BannerSection.Builder), [ChipSection.Builder](https://developer.android.com/reference/androidx/car/app/model/ChipSection.Builder), [CondensedSection.Builder](https://developer.android.com/reference/androidx/car/app/model/CondensedSection.Builder), [GridSection.Builder](https://developer.android.com/reference/androidx/car/app/model/GridSection.Builder), [RowSection.Builder](https://developer.android.com/reference/androidx/car/app/model/RowSection.Builder), [SpotlightSection.Builder](https://developer.android.com/reference/androidx/car/app/model/SpotlightSection.Builder)

|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/BannerSection.Builder` | A builder that constructs `https://developer.android.com/reference/androidx/car/app/model/BannerSection` instances. |
| `https://developer.android.com/reference/androidx/car/app/model/ChipSection.Builder` | A builder of `https://developer.android.com/reference/androidx/car/app/model/ChipSection`. |
| `https://developer.android.com/reference/androidx/car/app/model/CondensedSection.Builder` | A builder for `https://developer.android.com/reference/androidx/car/app/model/CondensedSection`. |
| `https://developer.android.com/reference/androidx/car/app/model/GridSection.Builder` | A builder that constructs `https://developer.android.com/reference/androidx/car/app/model/GridSection` instances. |
| `https://developer.android.com/reference/androidx/car/app/model/RowSection.Builder` | A builder that constructs `https://developer.android.com/reference/androidx/car/app/model/RowSection` instances. |
| `https://developer.android.com/reference/androidx/car/app/model/SpotlightSection.Builder` | A builder of `https://developer.android.com/reference/androidx/car/app/model/SpotlightSection`. |

*** ** * ** ***

Generic `https://developer.android.com/reference/androidx/car/app/model/Section` builder that contains the fields that all sections share.

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/androidx/car/app/model/Item>` | The `https://developer.android.com/reference/androidx/car/app/model/Item` type that this section contains |
| `<B>` | The builder type to return for the builder methods |

## Summary

| ### Protected constructors |
|---|
| `https://developer.android.com/reference/androidx/car/app/model/Section.BaseBuilder#BaseBuilder()()` |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html B` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/Section.BaseBuilder#addItem(T)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html T item)` Adds an item to this section, appending to the existing list of items. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html B` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/Section.BaseBuilder#clearItems()()` Delete all items in this section. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html B` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/Section.BaseBuilder#setItems(java.util.List<T>)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/List.html<T> items)` Sets the items for this section, overwriting any other previously set items. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html B` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/Section.BaseBuilder#setNoItemsMessage(androidx.car.app.model.CarText)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarText noItemsMessage)` Sets or clears the optional message to display in this section when there are 0 items added to it. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html B` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/Section.BaseBuilder#setNoItemsMessage(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html noItemsMessage)` Sets or clears the optional message to display in this section when there are 0 items added to it. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html B` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/Section.BaseBuilder#setOnItemVisibilityChangedListener(androidx.car.app.model.ItemList.OnItemVisibilityChangedListener)( @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/ItemList.OnItemVisibilityChangedListener onItemVisibilityChangedListener )` Sets the `https://developer.android.com/reference/androidx/car/app/model/ItemList.OnItemVisibilityChangedListener` to call when the visible items in this `https://developer.android.com/reference/androidx/car/app/model/Section` changes. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html B` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html @https://developer.android.com/reference/androidx/car/app/annotations/RequiresCarApi(value = 9) @https://developer.android.com/reference/androidx/car/app/annotations/ExperimentalCarApi https://developer.android.com/reference/androidx/car/app/model/Section.BaseBuilder#setSectionHeader(androidx.car.app.model.SectionHeader)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/SectionHeader sectionHeader)` Sets the `https://developer.android.com/reference/androidx/car/app/model/SectionHeader` for this section. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html B` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/Section.BaseBuilder#setTitle(androidx.car.app.model.CarText)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarText title)` Sets or clears the optional title that appears above the items in this section. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html B` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/Section.BaseBuilder#setTitle(java.lang.CharSequence)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/CharSequence.html title)` Sets or clears the optional title that appears above the items in this section. |

## Protected constructors

### BaseBuilder

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

```
protected BaseBuilder()
```

## Public methods

### addItem

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

```
@CanIgnoreReturnValue
public @NonNull B addItem(@NonNull T item)
```

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

### clearItems

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

```
@CanIgnoreReturnValue
public @NonNull B clearItems()
```

Delete all items in this section.

### setItems

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

```
@CanIgnoreReturnValue
public @NonNull B setItems(@NonNull List<T> items)
```

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

### setNoItemsMessage

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

```
@CanIgnoreReturnValue
public @NonNull B setNoItemsMessage(@Nullable CarText noItemsMessage)
```

Sets or clears the optional message to display in this section when there are 0 items added to it. If not set, this section will not show any message when there are 0 items. The message must conform to constraints.

### setNoItemsMessage

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

```
@CanIgnoreReturnValue
public @NonNull B setNoItemsMessage(@Nullable CharSequence noItemsMessage)
```

Sets or clears the optional message to display in this section when there are 0 items added to it. If not set, this section will not show any message when there are 0 items. The message must conform to constraints.

### setOnItemVisibilityChangedListener

Added in [1.8.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.8.0)

```
@CanIgnoreReturnValue
public @NonNull B setOnItemVisibilityChangedListener(
    @Nullable ItemList.OnItemVisibilityChangedListener onItemVisibilityChangedListener
)
```

Sets the `https://developer.android.com/reference/androidx/car/app/model/ItemList.OnItemVisibilityChangedListener` to call when the visible items in this `https://developer.android.com/reference/androidx/car/app/model/Section` changes.

Note that the listener relates to UI events and will be executed on the main thread using `Looper#getMainLooper()`.

It's possible for more than 1 `https://developer.android.com/reference/androidx/car/app/model/Section` to be visible on the screen at the same time, in which case, every visible Section's `https://developer.android.com/reference/androidx/car/app/model/ItemList.OnItemVisibilityChangedListener` will be triggered with their respective visible items.

Passing `null` will clear the `https://developer.android.com/reference/androidx/car/app/model/ItemList.OnItemVisibilityChangedListener`.

### setSectionHeader

Added in [1.9.0-alpha03](https://developer.android.com/jetpack/androidx/releases/car-app#1.9.0-alpha03)

```
@CanIgnoreReturnValue
@RequiresCarApi(value = 9)
@ExperimentalCarApi
public @NonNull B setSectionHeader(@Nullable SectionHeader sectionHeader)
```

Sets the `https://developer.android.com/reference/androidx/car/app/model/SectionHeader` for this section.

If this is set, it takes precedence over the title set via `https://developer.android.com/reference/androidx/car/app/model/Section.BaseBuilder#setTitle(java.lang.CharSequence)`.

### setTitle

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

```
@CanIgnoreReturnValue
public @NonNull B setTitle(@Nullable CarText title)
```

Sets or clears the optional title that appears above the items in this section. If not set, no title shows up. The title must conform to constraints.

Note: if `https://developer.android.com/reference/androidx/car/app/model/Section.BaseBuilder#setSectionHeader(androidx.car.app.model.SectionHeader)` is used, that header takes precedence and this title is ignored.

### setTitle

Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

```
@CanIgnoreReturnValue
public @NonNull B setTitle(@Nullable CharSequence title)
```

Sets or clears the optional title that appears above the items in this section. If not set, no title shows up. The title must conform to constraints.

Note: if `https://developer.android.com/reference/androidx/car/app/model/Section.BaseBuilder#setSectionHeader(androidx.car.app.model.SectionHeader)` is used, that header takes precedence and this title is ignored.