{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

LazyLayoutItemProvider

@ExperimentalFoundationApi
public interface LazyLayoutItemProvider


Provides all the needed info about the items which could be later composed and displayed as children or LazyLayout.

Summary

Public methods

abstract void
@Composable
Item(int index, @NonNull Object key)

The item for the given index and key.

default Object
getContentType(int index)

Returns the content type for the item on this index.

default int

Get index for given key.

abstract int

The total number of items in the lazy layout (visible or not).

default @NonNull Object
getKey(int index)

Returns the key for the item on this index.

Public methods

Item

@Composable
abstract void Item(int index, @NonNull Object key)

The item for the given index and key.

getContentType

default Object getContentType(int index)

Returns the content type for the item on this index. It is used to improve the item compositions reusing efficiency. Note that null is a valid type and items of such type will be considered compatible.

getIndex

default int getIndex(@NonNull Object key)

Get index for given key. The index is not guaranteed to be known for all keys in layout for optimization purposes, but must be present for elements in current viewport. If the key is not present in the layout or near current viewport, return -1.

getItemCount

abstract int getItemCount()

The total number of items in the lazy layout (visible or not).

getKey

default @NonNull Object getKey(int index)

Returns the key for the item on this index.

See also
getDefaultLazyLayoutKey

which you can use if the user didn't provide a key.