https://kotlinlang.org logo
Title
d

dan.the.man

08/13/2021, 3:43 PM
Someone posted a solution like
LazyColumn(
    modifier = Modifier.fillMaxSize(),
) {
    // My Books section
    item {
        Column(modifier = Modifier.fillMaxWidth()) {
            Text("My Books")
            LazyRow {
                items(books) { item ->
                    // Each Item
                }
            }
        }

    }
    // Whishlisted Books title
    item {
        Text("Whishlisted Books", style = MaterialTheme.typography.h4)
    }
    // Turning the list in a list of lists of two elements each
    items(wishlisted.windowed(2, 2, true)) { item ->
        Row {
            // Draw item[0]
            // Draw item[1]
        }
    }
}
to a SO question, but what is the point of multiple
item{}
blocks instead of just having it all in one?
v

Vitaliy Zarubin

08/13/2021, 3:49 PM
// item or items?
item {
    (0..10).forEach {

    }
}

(0..10).forEach {
    // item, no doubt
    item {

    }
}
k

kevindmoore

08/13/2021, 4:00 PM
Just a guess, but I would think each item is like a row in RecyclerView and treated that way
d

dan.the.man

08/13/2021, 4:01 PM
I understand the point of the item vs items, but not sure why they have two
item{}
on top of each other, just trying to see if I'm missing something
k

kevindmoore

08/13/2021, 4:37 PM
I think if you just have a few items, it is easier to just list them as item{}. If you have lists, you could use the forEach
c

Colton Idle

08/14/2021, 5:17 PM
I don't think it actually matters.