# TileRenderer

Artifact: [androidx.wear.tiles:tiles-renderer](https://developer.android.com/jetpack/androidx/releases/wear-tiles) [View Source](https://cs.android.com/search?q=file:androidx/wear/tiles/renderer/TileRenderer.java+class:androidx.wear.tiles.renderer.TileRenderer) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.0.0)

*** ** * ** ***

<br />

```
public final class TileRenderer
```

<br />

*** ** * ** ***

Renderer for Wear Tiles.

This variant uses Android views to represent the contents of the Wear Tile.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer.Builder` Builder for `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer`. |
| `public interface https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer.LoadActionListener` **This interface is deprecated.** Use `https://developer.android.com/reference/java/util/function/Consumer.html` with `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#TileRenderer(android.content.Context,java.util.concurrent.Executor,java.util.function.Consumer<androidx.wear.protolayout.StateBuilders.State>)`. <br /> |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#TileRenderer(android.content.Context,java.util.concurrent.Executor,java.util.function.Consumer<androidx.wear.protolayout.StateBuilders.State>)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html uiContext, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html loadActionExecutor, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/function/Consumer.html<https://developer.android.com/reference/androidx/wear/protolayout/StateBuilders.State> loadActionListener )` Constructor for `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer`. |
| `[TileRenderer](https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#TileRenderer(android.content.Context,androidx.wear.tiles.LayoutElementBuilders.Layout,androidx.wear.tiles.ResourceBuilders.Resources,java.util.concurrent.Executor,androidx.wear.tiles.renderer.TileRenderer.LoadActionListener))( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html uiContext, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/LayoutElementBuilders.Layout layout, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/ResourceBuilders.Resources resources, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html loadActionExecutor, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer.LoadActionListener loadActionListener )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer.Builder` which accepts Layout and Resources in `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#inflateAsync(androidx.wear.protolayout.LayoutElementBuilders.Layout,androidx.wear.protolayout.ResourceBuilders.Resources,android.view.ViewGroup)` method. <br /> |
| `[TileRenderer](https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#TileRenderer(android.content.Context,androidx.wear.tiles.LayoutElementBuilders.Layout,int,androidx.wear.tiles.ResourceBuilders.Resources,java.util.concurrent.Executor,androidx.wear.tiles.renderer.TileRenderer.LoadActionListener))( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html uiContext, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/LayoutElementBuilders.Layout layout, @https://developer.android.com/reference/androidx/annotation/StyleRes int tilesTheme, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/ResourceBuilders.Resources resources, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html loadActionExecutor, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer.LoadActionListener loadActionListener )` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer.Builder` which accepts Layout and Resources in `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#inflateAsync(androidx.wear.protolayout.LayoutElementBuilders.Layout,androidx.wear.protolayout.ResourceBuilders.Resources,android.view.ViewGroup)` method. <br /> |

| ### Public methods |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html` | `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#getLoadActionExecutor()()` Returns the `https://developer.android.com/reference/java/util/concurrent/Executor.html` for `loadActionListener`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/function/Consumer.html<https://developer.android.com/reference/androidx/wear/protolayout/StateBuilders.State>` | `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#getLoadActionListener()()` Returns the Listener for clicks that will cause the contents to be reloaded. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/androidx/wear/protolayout/expression/pipeline/PlatformDataProvider, https://developer.android.com/reference/java/util/Set.html<https://developer.android.com/reference/androidx/wear/protolayout/expression/PlatformDataKey<@https://developer.android.com/reference/androidx/annotation/NonNull ?>>>` | `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#getPlatformDataProviders()()` Returns the platform data providers that will be registered for this Tile instance. |
| `int` | `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#getTilesTheme()()` Returns the theme to use for this Tile instance. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html` | `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#getUiContext()()` Returns the `https://developer.android.com/reference/android/content/Context.html` suitable for interacting with the UI. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/View.html` | `[inflate](https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#inflate(android.view.ViewGroup))(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewGroup.html parent)` **This method is deprecated.** Use `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#inflateAsync(androidx.wear.protolayout.LayoutElementBuilders.Layout,androidx.wear.protolayout.ResourceBuilders.Resources,android.view.ViewGroup)` instead. <br /> |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/android/view/View.html>` | `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#inflateAsync(androidx.wear.protolayout.LayoutElementBuilders.Layout,androidx.wear.protolayout.ResourceBuilders.Resources,android.view.ViewGroup)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Layout layout, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/ResourceBuilders.Resources resources, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewGroup.html parent )` Inflates a Tile into `parent`. |
| `void` | `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#setState(java.util.Map<androidx.wear.protolayout.expression.AppDataKey<?>,androidx.wear.protolayout.expression.DynamicDataBuilders.DynamicDataValue<?>>)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/androidx/wear/protolayout/expression/AppDataKey<@https://developer.android.com/reference/androidx/annotation/NonNull ?>, https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataBuilders.DynamicDataValue<@https://developer.android.com/reference/androidx/annotation/NonNull ?>> newState )` Sets the state for the current (and future) layouts. |

## Public constructors

### TileRenderer

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.2.0)

```
public TileRenderer(
    @NonNull Context uiContext,
    @NonNull Executor loadActionExecutor,
    @NonNull Consumer<StateBuilders.State> loadActionListener
)
```

Constructor for `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer`.

It is recommended to use the new `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer.Builder` instead.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html uiContext` | A `https://developer.android.com/reference/android/content/Context.html` suitable for interacting with the UI. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html loadActionExecutor` | Executor for `loadActionListener`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/function/Consumer.html<https://developer.android.com/reference/androidx/wear/protolayout/StateBuilders.State> loadActionListener` | Listener for clicks that will cause the contents to be reloaded. |

### TileRenderer

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.0.0) Deprecated in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.2.0)

```
public [TileRenderer](https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#TileRenderer(android.content.Context,androidx.wear.tiles.LayoutElementBuilders.Layout,androidx.wear.tiles.ResourceBuilders.Resources,java.util.concurrent.Executor,androidx.wear.tiles.renderer.TileRenderer.LoadActionListener))(
    @NonNull Context uiContext,
    @NonNull LayoutElementBuilders.Layout layout,
    @NonNull ResourceBuilders.Resources resources,
    @NonNull Executor loadActionExecutor,
    @NonNull TileRenderer.LoadActionListener loadActionListener
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer.Builder` which accepts Layout and Resources in `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#inflateAsync(androidx.wear.protolayout.LayoutElementBuilders.Layout,androidx.wear.protolayout.ResourceBuilders.Resources,android.view.ViewGroup)` method.

Default constructor.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html uiContext` | A `https://developer.android.com/reference/android/content/Context.html` suitable for interacting with the UI. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/LayoutElementBuilders.Layout layout` | The portion of the Tile to render. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/ResourceBuilders.Resources resources` | The resources for the Tile. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html loadActionExecutor` | Executor for `loadActionListener`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer.LoadActionListener loadActionListener` | Listener for clicks that will cause the contents to be reloaded. |

### TileRenderer

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.0.0) Deprecated in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.2.0)

```
public [TileRenderer](https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#TileRenderer(android.content.Context,androidx.wear.tiles.LayoutElementBuilders.Layout,int,androidx.wear.tiles.ResourceBuilders.Resources,java.util.concurrent.Executor,androidx.wear.tiles.renderer.TileRenderer.LoadActionListener))(
    @NonNull Context uiContext,
    @NonNull LayoutElementBuilders.Layout layout,
    @StyleRes int tilesTheme,
    @NonNull ResourceBuilders.Resources resources,
    @NonNull Executor loadActionExecutor,
    @NonNull TileRenderer.LoadActionListener loadActionListener
)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer.Builder` which accepts Layout and Resources in `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#inflateAsync(androidx.wear.protolayout.LayoutElementBuilders.Layout,androidx.wear.protolayout.ResourceBuilders.Resources,android.view.ViewGroup)` method.

Default constructor.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/Context.html uiContext` | A `https://developer.android.com/reference/android/content/Context.html` suitable for interacting with the UI. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/LayoutElementBuilders.Layout layout` | The portion of the Tile to render. |
| `@https://developer.android.com/reference/androidx/annotation/StyleRes int tilesTheme` | The theme to use for this Tile instance. This can be used to customise things like the default font family. Pass 0 to use the default theme. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/ResourceBuilders.Resources resources` | The resources for the Tile. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/concurrent/Executor.html loadActionExecutor` | Executor for `loadActionListener`. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer.LoadActionListener loadActionListener` | Listener for clicks that will cause the contents to be reloaded. |

## Public methods

### getLoadActionExecutor

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

```
public @NonNull Executor getLoadActionExecutor()
```

Returns the `https://developer.android.com/reference/java/util/concurrent/Executor.html` for `loadActionListener`.

### getLoadActionListener

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

```
public @NonNull Consumer<StateBuilders.State> getLoadActionListener()
```

Returns the Listener for clicks that will cause the contents to be reloaded.

### getPlatformDataProviders

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

```
public @NonNull Map<PlatformDataProvider, Set<PlatformDataKey<@NonNull ?>>> getPlatformDataProviders()
```

Returns the platform data providers that will be registered for this Tile instance.

### getTilesTheme

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

```
public int getTilesTheme()
```

Returns the theme to use for this Tile instance. This can be used to customise things like the default font family. Defaults to zero (default theme) if not specified by `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer.Builder#setTilesTheme(int)`.

### getUiContext

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

```
public @NonNull Context getUiContext()
```

Returns the `https://developer.android.com/reference/android/content/Context.html` suitable for interacting with the UI.

### inflate

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.0.0) Deprecated in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.2.0)

```
public @Nullable View [inflate](https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#inflate(android.view.ViewGroup))(@NonNull ViewGroup parent)
```

> [!CAUTION]
> **This method is deprecated.**   
>
> Use `https://developer.android.com/reference/androidx/wear/tiles/renderer/TileRenderer#inflateAsync(androidx.wear.protolayout.LayoutElementBuilders.Layout,androidx.wear.protolayout.ResourceBuilders.Resources,android.view.ViewGroup)` instead. Note: This method only works with the deprecated constructors that accept Layout and Resources.

Inflates a Tile into `parent`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewGroup.html parent` | The view to attach the tile into. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/view/View.html` | The first child that was inflated. This may be null if the Layout is empty or the top-level LayoutElement has no inner set, or the top-level LayoutElement contains an unsupported inner type. |

### inflateAsync

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.2.0)

```
public @NonNull ListenableFuture<View> inflateAsync(
    @NonNull LayoutElementBuilders.Layout layout,
    @NonNull ResourceBuilders.Resources resources,
    @NonNull ViewGroup parent
)
```

Inflates a Tile into `parent`.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Layout layout` | The portion of the Tile to render. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/androidx/wear/protolayout/ResourceBuilders.Resources resources` | The resources for the Tile. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/view/ViewGroup.html parent` | The view to attach the tile into. |

| Returns |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://guava.dev/releases/snapshot-android/api/docs/com/google/common/util/concurrent/ListenableFuture.html<https://developer.android.com/reference/android/view/View.html>` | The future with the first child that was inflated. This may be null if the Layout is empty or the top-level LayoutElement has no inner set, or the top-level LayoutElement contains an unsupported inner type. |

### setState

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-tiles#1.2.0)

```
public void setState(
    @NonNull Map<AppDataKey<@NonNull ?>, DynamicDataBuilders.DynamicDataValue<@NonNull ?>> newState
)
```

Sets the state for the current (and future) layouts. This is equivalent to setting the tile state via `https://developer.android.com/reference/androidx/wear/protolayout/StateBuilders.State.Builder#addKeyToValueMapping(androidx.wear.protolayout.expression.AppDataKey<T>,androidx.wear.protolayout.expression.DynamicDataBuilders.DynamicDataValue<T>)`

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/util/Map.html<https://developer.android.com/reference/androidx/wear/protolayout/expression/AppDataKey<@https://developer.android.com/reference/androidx/annotation/NonNull ?>, https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataBuilders.DynamicDataValue<@https://developer.android.com/reference/androidx/annotation/NonNull ?>> newState` | the state to use for the current layout (and any future layouts). This value will replace any previously set state. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalStateException.html` | if number of `newState` entries is greater than `https://developer.android.com/reference/androidx/wear/protolayout/expression/pipeline/StateStore#getMaxStateEntryCount()`. |