Colton Idle
12/05/2020, 8:39 AMLazyColumn {
item {
Text("MAIN HEADER")
}
items(mylist.sections) { section: MyClass.Section ->
Text(section.title)
section.subsections.forEach {
Text(it.body)
}
}
}
this does not work, but it's what I expected I should do
LazyColumn {
item {
Text("MAIN HEADER")
}
items(mylist.sections) { section: MyClass.Section ->
Text(section.title)
item(sec.subsections) {
Text(it.body)
}
}
}
Andrey Kulikov
12/05/2020, 1:37 PMLazyColumn {
item {
Text("MAIN HEADER")
}
mylist.sections.forEach { section: MyClass.Section ->
item {
Text(section.title)
}
items(section.subsections) {
Text(it.body)
}
}
}
Colton Idle
12/05/2020, 9:19 PMThe vertically scrolling list that only composes and lays out the currently visible items. The content block defines a DSL which allows you to emit items of different types. For example you can use LazyListScope.item to add a single item and LazyListScope.items to add a list of items.Why does mylist.sections.ForEach work here? Edit: Bonus if you can point me towards a doc or a sample that shows that this is the recommended way?
Andrey Kulikov
01/19/2021, 11:26 AMmylist.sections.forEach { section: MyClass.Section ->
item {
Text(section.title)
}
items(section.subsections) {
Text(it.body)
}
}
is the same as doing something like
item {
Text(mylist.sections[0].title)
}
items(mylist.sections[0].subsections) {
Text(it.body)
}
item {
Text(mylist.sections[1].title)
}
items(mylist.sections[1].subsections) {
Text(it.body)
}
... and so on
Colton Idle
01/19/2021, 1:40 PMAndrey Kulikov
01/19/2021, 2:45 PMColton Idle
01/19/2021, 2:52 PMitem
or items
then you will get "recycling"?Andrey Kulikov
01/19/2021, 2:53 PMColton Idle
01/19/2021, 2:55 PMitem
or items
"Andrey Kulikov
01/19/2021, 3:01 PMLazyColumn {
item {
list.forEach {
Text(it)
}
}
}
because here we compose everything in one “item” call, so there is no lazinessColton Idle
01/19/2021, 3:03 PM