# 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 />

```
class TileRenderer
```

<br />

*** ** * ** ***

Renderer for Wear Tiles.

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

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/wear/tiles/renderer/TileRenderer.Builder` Builder for `https://developer.android.com/reference/kotlin/androidx/wear/tiles/renderer/TileRenderer`. |
| `interface https://developer.android.com/reference/kotlin/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/kotlin/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/kotlin/androidx/wear/tiles/renderer/TileRenderer#TileRenderer(android.content.Context,java.util.concurrent.Executor,java.util.function.Consumer<androidx.wear.protolayout.StateBuilders.State>)( uiContext: https://developer.android.com/reference/android/content/Context.html, loadActionExecutor: https://developer.android.com/reference/java/util/concurrent/Executor.html, loadActionListener: https://developer.android.com/reference/java/util/function/Consumer.html<https://developer.android.com/reference/kotlin/androidx/wear/protolayout/StateBuilders.State!> )` Constructor for `https://developer.android.com/reference/kotlin/androidx/wear/tiles/renderer/TileRenderer`. |
| `[TileRenderer](https://developer.android.com/reference/kotlin/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))( uiContext: https://developer.android.com/reference/android/content/Context.html, layout: https://developer.android.com/reference/kotlin/androidx/wear/tiles/LayoutElementBuilders.Layout, resources: https://developer.android.com/reference/kotlin/androidx/wear/tiles/ResourceBuilders.Resources, loadActionExecutor: https://developer.android.com/reference/java/util/concurrent/Executor.html, loadActionListener: https://developer.android.com/reference/kotlin/androidx/wear/tiles/renderer/TileRenderer.LoadActionListener )` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/wear/tiles/renderer/TileRenderer.Builder` which accepts Layout and Resources in `https://developer.android.com/reference/kotlin/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/kotlin/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))( uiContext: https://developer.android.com/reference/android/content/Context.html, layout: https://developer.android.com/reference/kotlin/androidx/wear/tiles/LayoutElementBuilders.Layout, tilesTheme: @https://developer.android.com/reference/kotlin/androidx/annotation/StyleRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, resources: https://developer.android.com/reference/kotlin/androidx/wear/tiles/ResourceBuilders.Resources, loadActionExecutor: https://developer.android.com/reference/java/util/concurrent/Executor.html, loadActionListener: https://developer.android.com/reference/kotlin/androidx/wear/tiles/renderer/TileRenderer.LoadActionListener )` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/wear/tiles/renderer/TileRenderer.Builder` which accepts Layout and Resources in `https://developer.android.com/reference/kotlin/androidx/wear/tiles/renderer/TileRenderer#inflateAsync(androidx.wear.protolayout.LayoutElementBuilders.Layout,androidx.wear.protolayout.ResourceBuilders.Resources,android.view.ViewGroup)` method. <br /> |

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/java/util/concurrent/Executor.html` | `https://developer.android.com/reference/kotlin/androidx/wear/tiles/renderer/TileRenderer#getLoadActionExecutor()()` Returns the `https://developer.android.com/reference/java/util/concurrent/Executor.html` for `loadActionListener`. |
| `https://developer.android.com/reference/java/util/function/Consumer.html<https://developer.android.com/reference/kotlin/androidx/wear/protolayout/StateBuilders.State!>` | `https://developer.android.com/reference/kotlin/androidx/wear/tiles/renderer/TileRenderer#getLoadActionListener()()` Returns the Listener for clicks that will cause the contents to be reloaded. |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/pipeline/PlatformDataProvider!, (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-set/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-set/index.html<https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/PlatformDataKey<*>!>!>` | `https://developer.android.com/reference/kotlin/androidx/wear/tiles/renderer/TileRenderer#getPlatformDataProviders()()` Returns the platform data providers that will be registered for this Tile instance. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/tiles/renderer/TileRenderer#getTilesTheme()()` Returns the theme to use for this Tile instance. |
| `https://developer.android.com/reference/android/content/Context.html` | `https://developer.android.com/reference/kotlin/androidx/wear/tiles/renderer/TileRenderer#getUiContext()()` Returns the `https://developer.android.com/reference/android/content/Context.html` suitable for interacting with the UI. |
| `https://developer.android.com/reference/android/view/View.html?` | `[inflate](https://developer.android.com/reference/kotlin/androidx/wear/tiles/renderer/TileRenderer#inflate(android.view.ViewGroup))(parent: https://developer.android.com/reference/android/view/ViewGroup.html)` **This function is deprecated.** Use `https://developer.android.com/reference/kotlin/androidx/wear/tiles/renderer/TileRenderer#inflateAsync(androidx.wear.protolayout.LayoutElementBuilders.Layout,androidx.wear.protolayout.ResourceBuilders.Resources,android.view.ViewGroup)` instead. <br /> |
| `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/kotlin/androidx/wear/tiles/renderer/TileRenderer#inflateAsync(androidx.wear.protolayout.LayoutElementBuilders.Layout,androidx.wear.protolayout.ResourceBuilders.Resources,android.view.ViewGroup)( layout: https://developer.android.com/reference/kotlin/androidx/wear/protolayout/LayoutElementBuilders.Layout, resources: https://developer.android.com/reference/kotlin/androidx/wear/protolayout/ResourceBuilders.Resources, parent: https://developer.android.com/reference/android/view/ViewGroup.html )` Inflates a Tile into `parent`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/wear/tiles/renderer/TileRenderer#setState(java.util.Map<androidx.wear.protolayout.expression.AppDataKey<?>,androidx.wear.protolayout.expression.DynamicDataBuilders.DynamicDataValue<?>>)( newState: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/AppDataKey<*>!, https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/DynamicDataBuilders.DynamicDataValue<*>!> )` 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)

```
TileRenderer(
    uiContext: Context,
    loadActionExecutor: Executor,
    loadActionListener: Consumer<StateBuilders.State!>
)
```

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

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

| Parameters |
|---|---|
| `uiContext: https://developer.android.com/reference/android/content/Context.html` | A `https://developer.android.com/reference/android/content/Context.html` suitable for interacting with the UI. |
| `loadActionExecutor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | Executor for `loadActionListener`. |
| `loadActionListener: https://developer.android.com/reference/java/util/function/Consumer.html<https://developer.android.com/reference/kotlin/androidx/wear/protolayout/StateBuilders.State!>` | 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)

```
[TileRenderer](https://developer.android.com/reference/kotlin/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))(
    uiContext: Context,
    layout: LayoutElementBuilders.Layout,
    resources: ResourceBuilders.Resources,
    loadActionExecutor: Executor,
    loadActionListener: TileRenderer.LoadActionListener
)
```

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

Default constructor.

| Parameters |
|---|---|
| `uiContext: https://developer.android.com/reference/android/content/Context.html` | A `https://developer.android.com/reference/android/content/Context.html` suitable for interacting with the UI. |
| `layout: https://developer.android.com/reference/kotlin/androidx/wear/tiles/LayoutElementBuilders.Layout` | The portion of the Tile to render. |
| `resources: https://developer.android.com/reference/kotlin/androidx/wear/tiles/ResourceBuilders.Resources` | The resources for the Tile. |
| `loadActionExecutor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | Executor for `loadActionListener`. |
| `loadActionListener: https://developer.android.com/reference/kotlin/androidx/wear/tiles/renderer/TileRenderer.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)

```
[TileRenderer](https://developer.android.com/reference/kotlin/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))(
    uiContext: Context,
    layout: LayoutElementBuilders.Layout,
    tilesTheme: @StyleRes Int,
    resources: ResourceBuilders.Resources,
    loadActionExecutor: Executor,
    loadActionListener: TileRenderer.LoadActionListener
)
```

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

Default constructor.

| Parameters |
|---|---|
| `uiContext: https://developer.android.com/reference/android/content/Context.html` | A `https://developer.android.com/reference/android/content/Context.html` suitable for interacting with the UI. |
| `layout: https://developer.android.com/reference/kotlin/androidx/wear/tiles/LayoutElementBuilders.Layout` | The portion of the Tile to render. |
| `tilesTheme: @https://developer.android.com/reference/kotlin/androidx/annotation/StyleRes https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | 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. |
| `resources: https://developer.android.com/reference/kotlin/androidx/wear/tiles/ResourceBuilders.Resources` | The resources for the Tile. |
| `loadActionExecutor: https://developer.android.com/reference/java/util/concurrent/Executor.html` | Executor for `loadActionListener`. |
| `loadActionListener: https://developer.android.com/reference/kotlin/androidx/wear/tiles/renderer/TileRenderer.LoadActionListener` | Listener for clicks that will cause the contents to be reloaded. |

## Public functions

### getLoadActionExecutor

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

```
fun getLoadActionExecutor(): Executor
```

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)

```
fun getLoadActionListener(): Consumer<StateBuilders.State!>
```

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)

```
fun getPlatformDataProviders(): (Mutable)Map<PlatformDataProvider!, (Mutable)Set<PlatformDataKey<*>!>!>
```

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)

```
fun getTilesTheme(): Int
```

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/kotlin/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)

```
fun getUiContext(): Context
```

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)

```
fun [inflate](https://developer.android.com/reference/kotlin/androidx/wear/tiles/renderer/TileRenderer#inflate(android.view.ViewGroup))(parent: ViewGroup): View?
```

> [!CAUTION]
> **This function is deprecated.**   
>
> Use `https://developer.android.com/reference/kotlin/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 |
|---|---|
| `parent: https://developer.android.com/reference/android/view/ViewGroup.html` | The view to attach the tile into. |

| Returns |
|---|---|
| `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)

```
fun inflateAsync(
    layout: LayoutElementBuilders.Layout,
    resources: ResourceBuilders.Resources,
    parent: ViewGroup
): ListenableFuture<View!>
```

Inflates a Tile into `parent`.

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

| Returns |
|---|---|
| `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)

```
fun setState(
    newState: (Mutable)Map<AppDataKey<*>!, DynamicDataBuilders.DynamicDataValue<*>!>
): Unit
```

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

| Parameters |
|---|---|
| `newState: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-map/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-map/index.html<https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/AppDataKey<*>!, https://developer.android.com/reference/kotlin/androidx/wear/protolayout/expression/DynamicDataBuilders.DynamicDataValue<*>!>` | 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/kotlin/androidx/wear/protolayout/expression/pipeline/StateStore#getMaxStateEntryCount()`. |