Ali Albaali
12/11/2021, 8:05 PMLazyColum
? Let's say, I have Item1
and Item2
, I want to display one Item2
after every 5 items of Item1
.
My initial thought, is to make them inherit a single interface and handle them based on index. But is there any other way?mcpiroman
12/11/2021, 8:08 PMLazyColumn {
repeat(10) {
repeat(4) {
item { Item2() }
}
item { Item1() }
}
}
?Ali Albaali
12/11/2021, 9:12 PMitem
block. Thanksrcd27
12/16/2021, 6:00 AMsealed class
to describe the items, like
sealed class ItemViewObject {
object Item1: ItemViewObject()
object Item2: ItemViewObject()
}
After that, passing a List<ItemViewObjec>
to LazyColumn, where:
LazyColumn {
items.forEach{
when(it) {
is Item1 -> item { /** draw item-1 */ }
is Item2 -> item { /** draw item-2 */ }
}
}