public final class

GridItem.Builder

extends java.lang.Object

 java.lang.Object

↳androidx.car.app.model.GridItem.Builder

Overview

A builder of GridItem.

Summary

Constructors
publicBuilder()

Returns an empty GridItem.Builder instance.

Methods
public GridItembuild()

Constructs the GridItem defined by this builder.

public GridItem.BuildersetImage(CarIcon image)

Sets an image to show in the grid item with the default size GridItem.IMAGE_TYPE_LARGE.

public GridItem.BuildersetImage(CarIcon image, Badge badge)

Sets an image to show in the grid item with the given Badge to be displayed over the image, with the default size GridItem.IMAGE_TYPE_LARGE.

public GridItem.BuildersetImage(CarIcon image, int imageType)

Sets an image to show in the grid item with the given imageType.

public GridItem.BuildersetImage(CarIcon image, int imageType, Badge badge)

Sets an image to show in the grid item with the given imageType and given Badge to be displayed over the image.

public GridItem.BuildersetLoading(boolean isLoading)

Sets whether the item is in a loading state.

public GridItem.BuildersetOnClickListener(OnClickListener onClickListener)

Sets the OnClickListener to be called back when the grid item is clicked, or null to make the grid item non-clickable.

public GridItem.BuildersetText(CarText text)

Sets a secondary text string to the grid item that is displayed below the title, with support for multiple length variants.

public GridItem.BuildersetText(java.lang.CharSequence text)

Sets a secondary text string to the grid item that is displayed below the title.

public GridItem.BuildersetTitle(CarText title)

Sets the title of the GridItem, with support for multiple length variants.

public GridItem.BuildersetTitle(java.lang.CharSequence title)

Sets the title of the GridItem.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public Builder()

Returns an empty GridItem.Builder instance.

Methods

public GridItem.Builder setLoading(boolean isLoading)

Sets whether the item is in a loading state.

If set to true, the UI shows a loading indicator where the grid item would be otherwise. The caller is expected to call Screen.invalidate() and send the new template content to the host once the data is ready. If set to false, the UI shows the item contents.

public GridItem.Builder setTitle(java.lang.CharSequence title)

Sets the title of the GridItem.

title must conform to in Car API 7 and below, and in Car API 8 and above.

public GridItem.Builder setTitle(CarText title)

Sets the title of the GridItem, with support for multiple length variants.

title must conform to in Car API 7 and below, and in Car API 8 and above.

public GridItem.Builder setText(java.lang.CharSequence text)

Sets a secondary text string to the grid item that is displayed below the title.

text must conform to in Car API 7 and below, and in Car API 8 and above.

Text Wrapping

This text is truncated at the end to fit in a single line below the title

public GridItem.Builder setText(CarText text)

Sets a secondary text string to the grid item that is displayed below the title, with support for multiple length variants.

text must conform to in Car API 7 and below, and in Car API 8 and above.

Text Wrapping

This text is truncated at the end to fit in a single line below the title

public GridItem.Builder setImage(CarIcon image)

Sets an image to show in the grid item with the default size GridItem.IMAGE_TYPE_LARGE.

See also: GridItem.Builder.setImage(CarIcon, int)

public GridItem.Builder setImage(CarIcon image, Badge badge)

Sets an image to show in the grid item with the given Badge to be displayed over the image, with the default size GridItem.IMAGE_TYPE_LARGE.

A dot badge denotes some sort of call to action or notification and is displayed in the upper right corner of the image. An icon badge gives additional context about the image and is displayed in the lower right corner.

See also: GridItem.Builder.setImage(CarIcon, int)

public GridItem.Builder setImage(CarIcon image, int imageType, Badge badge)

Sets an image to show in the grid item with the given imageType and given Badge to be displayed over the image.

A dot badge denotes a call to action or notification and is displayed in the upper right corner of the image. An icon badge gives additional context about the image and is displayed in the lower right corner.

See also: GridItem.Builder.setImage(CarIcon, int)

public GridItem.Builder setImage(CarIcon image, int imageType)

Sets an image to show in the grid item with the given imageType.

For a custom CarIcon, its IconCompat instance can be of IconCompat.TYPE_BITMAP, IconCompat.TYPE_RESOURCE, or IconCompat.TYPE_URI.

Image Sizing Guidance

If the input image's size exceeds the sizing requirements for the given image type in either one of the dimensions, it will be scaled down to be centered inside the bounding box while preserving its aspect ratio.

See CarIcon for more details related to providing icon and image resources that work with different car screen pixel densities.

Parameters:

image: the CarIcon to display
imageType: one of GridItem.IMAGE_TYPE_ICON or GridItem.IMAGE_TYPE_LARGE

public GridItem.Builder setOnClickListener(OnClickListener onClickListener)

Sets the OnClickListener to be called back when the grid item is clicked, or null to make the grid item non-clickable.

Note that the listener relates to UI events and will be executed on the main thread using

public GridItem build()

Constructs the GridItem defined by this builder.