Google is committed to advancing racial equity for Black communities. See how.

InlinePresentationBuilder

public class InlinePresentationBuilder
extends Object

java.lang.Object
   ↳ androidx.autofill.InlinePresentationBuilder


Helper class to create Slice for rendering into inline suggestions.

This builder is used by AutofillService and providers to create slices representing their inline suggestions UI.

TODO(b/147116534): Add documentation about UI templating.

Summary

Public constructors

InlinePresentationBuilder(CharSequence title)

Initializes an InlinePresentationBuilder with title text.

InlinePresentationBuilder()

Initializes a an InlinePresentationBuilder.

Public methods

Slice build()

Creates a new Slice instance.

InlinePresentationBuilder setAction(PendingIntent action)

Sets the action of Slice.

InlinePresentationBuilder setEndIcon(Icon endIcon)

Sets the end icon of Slice.

InlinePresentationBuilder setStartIcon(Icon startIcon)

Sets the start icon of Slice.

InlinePresentationBuilder setSubtitle(CharSequence subtitle)

Sets the subtitle of Slice.

Inherited methods

Public constructors

InlinePresentationBuilder

public InlinePresentationBuilder (CharSequence title)

Initializes an InlinePresentationBuilder with title text.

Parameters
title CharSequence: String displayed as title of slice.

InlinePresentationBuilder

public InlinePresentationBuilder ()

Initializes a an InlinePresentationBuilder.

Public methods

build

public Slice build ()

Creates a new Slice instance.

You should not interact with this builder once this method is called.

Returns
Slice The built slice.

Throws
IllegalStateException if none of the title, subtitle, start icon and end icon is set, or if the subtitle is set without the title.

setAction

public InlinePresentationBuilder setAction (PendingIntent action)

Sets the action of Slice.

Parameters
action PendingIntent: invoked when the slice is tapped.

Returns
InlinePresentationBuilder

setEndIcon

public InlinePresentationBuilder setEndIcon (Icon endIcon)

Sets the end icon of Slice.

Parameters
endIcon Icon: Icon resource displayed at end of slice.

Returns
InlinePresentationBuilder

setStartIcon

public InlinePresentationBuilder setStartIcon (Icon startIcon)

Sets the start icon of Slice.

Parameters
startIcon Icon: Icon resource displayed at start of slice.

Returns
InlinePresentationBuilder

setSubtitle

public InlinePresentationBuilder setSubtitle (CharSequence subtitle)

Sets the subtitle of Slice.

Parameters
subtitle CharSequence: String displayed as subtitle of slice.

Returns
InlinePresentationBuilder