LazyListScope
interface LazyListScope
androidx.compose.foundation.lazy.LazyListScope |
Receiver scope which is used by LazyColumn and LazyRow.
Summary
Public methods | |
---|---|
abstract Unit |
item(content: LazyItemScope.() -> Unit) Adds a single item to the scope. |
abstract Unit |
items(items: List<T>, itemContent: LazyItemScope.(item: T) -> Unit) Adds a list of items and their content to the scope. |
abstract Unit |
itemsIndexed(items: List<T>, itemContent: LazyItemScope.(index: Int, item: T) -> Unit) Adds a list of items to the scope where the content of an item is aware of its index. |
abstract Unit |
stickyHeader(content: LazyItemScope.() -> Unit) Adds a sticky header item, which will remain pinned even when scrolling after it. |
Extension functions | ||||
---|---|---|---|---|
From androidx.paging.compose
|
Public methods
item
abstract fun item(content: LazyItemScope.() -> Unit): Unit
Adds a single item to the scope.
Parameters | |
---|---|
content: LazyItemScope.() -> Unit | the content of the item |
items
abstract fun <T> items(
items: List<T>,
itemContent: LazyItemScope.(item: T) -> Unit
): Unit
Adds a list of items and their content to the scope.
Parameters | |
---|---|
items: List<T> | the data list |
itemContent: LazyItemScope.(item: T) -> Unit | the content displayed by a single item |
itemsIndexed
abstract fun <T> itemsIndexed(
items: List<T>,
itemContent: LazyItemScope.(index: Int, item: T) -> Unit
): Unit
Adds a list of items to the scope where the content of an item is aware of its index.
Parameters | |
---|---|
items: List<T> | the data list |
itemContent: LazyItemScope.(index: Int, item: T) -> Unit | the content displayed by a single item |
stickyHeader
abstract fun stickyHeader(content: LazyItemScope.() -> Unit): Unit
Adds a sticky header item, which will remain pinned even when scrolling after it. The header will remain pinned until the next header will take its place.
import androidx.compose.foundation.background import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.material.Text val sections = listOf("A", "B", "C", "D", "E", "F", "G") LazyColumn { sections.forEach { section -> stickyHeader { Text( "Section $section", Modifier.fillMaxWidth().background(Color.LightGray).padding(8.dp) ) } items((0..9).toList()) { Text("Item $it from the section $section") } } }
Parameters | |
---|---|
content: LazyItemScope.() -> Unit | the content of the header |