# Section

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) Added in [1.7.0](https://developer.android.com/jetpack/androidx/releases/car-app#1.7.0)

*** ** * ** ***


```
@CarProtocol
@RequiresCarApi(value = 8)
public abstract class Section<T extends Item>
```

<br />

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

|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/BannerSection` | A section within the `SectionedItemTemplate` that contains a `https://developer.android.com/reference/androidx/car/app/model/Banner`. |
| `https://developer.android.com/reference/androidx/car/app/model/ChipSection` | A section of `https://developer.android.com/reference/androidx/car/app/model/Chip`s. |
| `https://developer.android.com/reference/androidx/car/app/model/CondensedSection` | A `https://developer.android.com/reference/androidx/car/app/model/Section` within the `SectionedItemTemplate` that contains `https://developer.android.com/reference/androidx/car/app/model/CondensedItem`s. |
| `https://developer.android.com/reference/androidx/car/app/model/GridSection` | A section within the `SectionedItemTemplate` that contains `https://developer.android.com/reference/androidx/car/app/model/GridItem`s - good for showcase large artwork or images for every entry. |
| `https://developer.android.com/reference/androidx/car/app/model/RowSection` | A section within the `SectionedItemTemplate` that contains `https://developer.android.com/reference/androidx/car/app/model/Row`s - good for showcasing small icons and longer text for every entry. |
| `https://developer.android.com/reference/androidx/car/app/model/SpotlightSection` | A section within the `https://developer.android.com/reference/androidx/car/app/model/SectionedItemTemplate` that contains a single image and multiple `https://developer.android.com/reference/androidx/car/app/model/CondensedItem`s. |

*** ** * ** ***

The generic interface for a single section within a sectioned item template. Sections only allow a single type of `https://developer.android.com/reference/androidx/car/app/model/Item` to be added.

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/androidx/car/app/model/Item>` | the type of `https://developer.android.com/reference/androidx/car/app/model/Item` that's allowed to be added to this section |

## Summary

| ### Nested types |
|---|
| `protected abstract class https://developer.android.com/reference/androidx/car/app/model/Section.BaseBuilder<T extends https://developer.android.com/reference/androidx/car/app/model/Item, B>` Generic `https://developer.android.com/reference/androidx/car/app/model/Section` builder that contains the fields that all sections share. |

| ### Protected constructors |
|---|
| `https://developer.android.com/reference/androidx/car/app/model/Section#Section()()` |
| `https://developer.android.com/reference/androidx/car/app/model/Section#Section(androidx.car.app.model.Section.BaseBuilder<T,?>)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/Section.BaseBuilder<T, @https://developer.android.com/reference/androidx/annotation/NonNull ?> builder)` Constructor that fills out fields from any section builder. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/Section#equals(java.lang.Object)(@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html other)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarText` | `https://developer.android.com/reference/androidx/car/app/model/Section#getNoItemsMessage()()` Returns the optional message that should appear if there are no items added to this section. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/OnItemVisibilityChangedDelegate` | `https://developer.android.com/reference/androidx/car/app/model/Section#getOnItemVisibilityChangedDelegate()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/OnItemVisibilityChangedDelegate` to be called when the visible items in this `https://developer.android.com/reference/androidx/car/app/model/Section` changes, or `null` if one isn't set. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/SectionHeader` | `@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#getSectionHeader()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/SectionHeader` for this section, or `null` if not set. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarText` | `https://developer.android.com/reference/androidx/car/app/model/Section#getTitle()()` Returns the optional text that should appear with the items in this section. |
| `int` | `https://developer.android.com/reference/androidx/car/app/model/Section#hashCode()()` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/car/app/model/Section#toString()()` |

## Protected constructors

### Section

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

```
protected Section()
```

### Section

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

```
protected Section(@NonNull Section.BaseBuilder<T, @NonNull ?> builder)
```

Constructor that fills out fields from any section builder.

## Public methods

### equals

```
public boolean equals(@Nullable Object other)
```

### getNoItemsMessage

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

```
public @Nullable CarText getNoItemsMessage()
```

Returns the optional message that should appear if there are no items added to this section.

### getOnItemVisibilityChangedDelegate

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

```
public @Nullable OnItemVisibilityChangedDelegate getOnItemVisibilityChangedDelegate()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/OnItemVisibilityChangedDelegate` to be called when the visible items in this `https://developer.android.com/reference/androidx/car/app/model/Section` changes, or `null` if one isn't set.

### getSectionHeader

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

```
@RequiresCarApi(value = 9)
@ExperimentalCarApi
public @Nullable SectionHeader getSectionHeader()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/SectionHeader` for this section, or `null` if not set.

If this is set, it takes precedence over `https://developer.android.com/reference/androidx/car/app/model/Section#getTitle()`.

### getTitle

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

```
public @Nullable CarText getTitle()
```

Returns the optional text that should appear with the items in this section.

If `https://developer.android.com/reference/androidx/car/app/model/Section#getSectionHeader()` is set, it takes precedence and this title should be ignored.

### hashCode

```
public int hashCode()
```

### toString

```
public @NonNull String toString()
```