# GridSection.Builder

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

*** ** * ** ***


```
public final class GridSection.Builder extends Section.BaseBuilder<GridItem, GridSection.Builder>
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.car.app.model.Section.BaseBuilder](https://developer.android.com/reference/androidx/car/app/model/Section.BaseBuilder)\<[GridItem](https://developer.android.com/reference/androidx/car/app/model/GridItem), [GridSection.Builder](https://developer.android.com/reference/androidx/car/app/model/GridSection.Builder)\> ||
|   | ↳ | [androidx.car.app.model.GridSection.Builder](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.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/car/app/model/GridSection.Builder#Builder()()` Create a new `https://developer.android.com/reference/androidx/car/app/model/GridSection` builder. |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/GridSection` | `https://developer.android.com/reference/androidx/car/app/model/GridSection.Builder#build()()` Creates a new `https://developer.android.com/reference/androidx/car/app/model/GridSection` based off the state of this builder. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/GridSection.Builder` | `@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/GridSection.Builder#setIncompleteLastRowStrategy(int)(int incompleteLastRowStrategy)` Sets the strategy to use for handling the incomplete last row |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/GridSection.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/GridSection.Builder#setItemImageShape(int)(int itemImageShape)` Sets how the images of all grid items within this section should be rendered. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/car/app/model/GridSection.Builder` | `@https://checkerframework.org/api/com/google/errorprone/annotations/CanIgnoreReturnValue.html https://developer.android.com/reference/androidx/car/app/model/GridSection.Builder#setItemSize(int)(int itemSize)` Sets the size of the items within this section. |

### Inherited methods

From [androidx.car.app.model.Section.BaseBuilder](https://developer.android.com/reference/androidx/car/app/model/Section.BaseBuilder) `@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.

## Public constructors

### Builder

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

```
public Builder()
```

Create a new `https://developer.android.com/reference/androidx/car/app/model/GridSection` builder.

## Public methods

### build

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

```
public @NonNull GridSection build()
```

Creates a new `https://developer.android.com/reference/androidx/car/app/model/GridSection` based off the state of this builder.

### setIncompleteLastRowStrategy

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 GridSection.Builder setIncompleteLastRowStrategy(int incompleteLastRowStrategy)
```

Sets the strategy to use for handling the incomplete last row

By default, `https://developer.android.com/reference/androidx/car/app/model/GridSection#INCOMPLETE_LAST_ROW_AS_IS()` is used.

### setItemImageShape

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

```
@CanIgnoreReturnValue
public @NonNull GridSection.Builder setItemImageShape(int itemImageShape)
```

Sets how the images of all grid items within this section should be rendered. Uses `https://developer.android.com/reference/androidx/car/app/model/GridSection#ITEM_IMAGE_SHAPE_UNSET()` by default.

### setItemSize

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

```
@CanIgnoreReturnValue
public @NonNull GridSection.Builder setItemSize(int itemSize)
```

Sets the size of the items within this section.