'jetpack compose LazyLayout parameters in not Specified
I want to develop a LazyLayout
in jetpack compose
@ExperimentalFoundationApi
@Composable
fun LazyLayout(
itemsProvider: LazyLayoutItemsProvider!,
modifier: Modifier! = Modifier,
prefetchState: LazyLayoutPrefetchState? = null,
measurePolicy: (@ExtensionFunctionType LazyLayoutMeasureScope.(Constraints) ->
MeasureResult)?
): Unit
there is two necessary parameters, itemsProvider
and measurePolicy
and this is all information about itemsProvider
parameter in document:
@param itemsProvider provides all the needed info about the items which could be used to compose and measure items as part of [measurePolicy].
I don't know how to provide this parameter for LazyLayout
.
any idea how it works?
Solution 1:[1]
You have to provide only "itemsProvider" parameter by creating object like this:
LazyLayout(
itemsProvider = object : LazyLayoutItemsProvider {
override fun getContent(index: Int): @Composable () -> Unit {
return {
//your content
}
}
override val itemsCount: Int
get() = //count content
override fun getKey(index: Int): Any = index
override val keyToIndexMap: Map<Any, Int> = emptyMap()
override fun getContentType(index: Int): Any? = null
},
//modifier = modifier
//.padding(paddingValues)
//.verticalScroll(state = state, flingBehavior = NoFlingBehavior)
) { constraints ->
//do whatever you want
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Pantsoffski |