# GridItem

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

*** ** * ** ***


```
@CarProtocol
public final class GridItem implements Item
```

<br />

*** ** * ** ***

Represents a grid item with an image and an optional title.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/car/app/model/GridItem.Builder` A builder of `https://developer.android.com/reference/androidx/car/app/model/GridItem`. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/car/app/model/GridItem#IMAGE_TYPE_ICON() = 1` **This field is deprecated.** Use `https://developer.android.com/reference/androidx/car/app/model/GridItem.Builder#setImage(androidx.car.app.model.CarIcon)` instead. <br /> |
| `static final int` | `https://developer.android.com/reference/androidx/car/app/model/GridItem#IMAGE_TYPE_LARGE() = 2` **This field is deprecated.** Use `https://developer.android.com/reference/androidx/car/app/model/GridItem.Builder#setImage(androidx.car.app.model.CarIcon)` instead. <br /> |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/GridItem#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/Badge` | `@https://developer.android.com/reference/androidx/car/app/annotations/RequiresCarApi(value = 8) https://developer.android.com/reference/androidx/car/app/model/GridItem#getBadge()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/Badge` that is displayed over the grid item image or `null` if not set. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarIcon` | `https://developer.android.com/reference/androidx/car/app/model/GridItem#getImage()()` Returns the image of the grid item or `null` if not set. |
| `int` | `https://developer.android.com/reference/androidx/car/app/model/GridItem#getImageType()()` Returns the image type of the grid item. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/OnClickDelegate` | `https://developer.android.com/reference/androidx/car/app/model/GridItem#getOnClickDelegate()()` Returns the `https://developer.android.com/reference/androidx/car/app/model/OnClickDelegate` to be called back when the grid item is clicked or `null` if the grid item is non-clickable. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/androidx/car/app/model/CarProgressBar` | `@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/GridItem#getProgressBar()()` Returns the progress bar to display in the grid item, 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/GridItem#getText()()` Returns the text to display below the title or `null` if no text will be displayed below the title. |
| `@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/GridItem#getTitle()()` Returns the title of the grid item or `null` if not set. |
| `int` | `https://developer.android.com/reference/androidx/car/app/model/GridItem#hashCode()()` |
| `boolean` | `@https://developer.android.com/reference/androidx/car/app/annotations/RequiresCarApi(value = 8) https://developer.android.com/reference/androidx/car/app/model/GridItem#isIndexable()()` Returns whether this item can be included in indexed lists. |
| `boolean` | `https://developer.android.com/reference/androidx/car/app/model/GridItem#isLoading()()` Returns whether the grid item is in a loading state. |
| `@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/GridItem#toString()()` |

## Constants

### IMAGE_TYPE_ICON

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

```
public static final int IMAGE_TYPE_ICON = 1
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/car/app/model/GridItem.Builder#setImage(androidx.car.app.model.CarIcon)` instead. Tint is controlled directly by `https://developer.android.com/reference/androidx/car/app/model/CarIcon`, and image size is controlled by the parent template or section (e.g. `https://developer.android.com/reference/androidx/car/app/model/GridSection.Builder#setItemSize(int)`).

Represents an icon to be displayed in the grid item.

To minimize scaling artifacts across a wide range of car screens, apps should provide icons targeting a 128 x 128 dp bounding box. If necessary, the icon will be scaled down while preserving its aspect ratio.

A tint color is expected to be provided via `https://developer.android.com/reference/androidx/car/app/model/CarIconStyle.Builder#setTint(androidx.car.app.model.CarColor)` provided to the icon with `https://developer.android.com/reference/androidx/car/app/model/CarIcon.Builder#setStyle(androidx.car.app.model.CarIconStyle)`. Otherwise, a default tint color as determined by the host will be applied.

### IMAGE_TYPE_LARGE

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

```
public static final int IMAGE_TYPE_LARGE = 2
```

> [!CAUTION]
> **This field is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/car/app/model/GridItem.Builder#setImage(androidx.car.app.model.CarIcon)` instead. Image size is controlled by the parent template or section (e.g. `https://developer.android.com/reference/androidx/car/app/model/GridSection.Builder#setItemSize(int)`), and tint is controlled directly by `https://developer.android.com/reference/androidx/car/app/model/CarIcon`.

Represents a large image to be displayed in the grid item.

To minimize scaling artifacts across a wide range of car screens, apps should provide images targeting a 128 x 128 dp bounding box. If necessary, the image will be scaled down while preserving its aspect ratio.

## Public methods

### equals

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

### getBadge

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

```
@RequiresCarApi(value = 8)
public @Nullable Badge getBadge()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/Badge` that is displayed over the grid item image or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/GridItem.Builder` |   |

### getImage

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

```
public @Nullable CarIcon getImage()
```

Returns the image of the grid item or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/GridItem.Builder#setImage(androidx.car.app.model.CarIcon)` |   |

### getImageType

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

```
public int getImageType()
```

Returns the image type of the grid item.

### getOnClickDelegate

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

```
public @Nullable OnClickDelegate getOnClickDelegate()
```

Returns the `https://developer.android.com/reference/androidx/car/app/model/OnClickDelegate` to be called back when the grid item is clicked or `null` if the grid item is non-clickable.

### getProgressBar

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

```
@RequiresCarApi(value = 9)
@ExperimentalCarApi
public @Nullable CarProgressBar getProgressBar()
```

Returns the progress bar to display in the grid item, or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/GridItem.Builder#setProgressBar(androidx.car.app.model.CarProgressBar)` |   |

### getText

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

```
public @Nullable CarText getText()
```

Returns the text to display below the title or `null` if no text will be displayed below the title.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/GridItem.Builder#setText(java.lang.CharSequence)` |   |

### getTitle

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

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

Returns the title of the grid item or `null` if not set.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/GridItem.Builder#setTitle(java.lang.CharSequence)` |   |

### hashCode

```
public int hashCode()
```

### isIndexable

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

```
@RequiresCarApi(value = 8)
public boolean isIndexable()
```

Returns whether this item can be included in indexed lists.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/GridItem.Builder#setIndexable(boolean)` |   |

### isLoading

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

```
public boolean isLoading()
```

Returns whether the grid item is in a loading state.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/car/app/model/GridItem.Builder#setLoading(boolean)` |   |

### toString

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