In my jetpack-compose app, I'm building a comment tree, where the top level, and the leaves, are lists, that would be best to use LazyColumn
.
This is of the form:
List<CommentNode>
...
CommentNode: {
content: String
children: List<CommentNode>
}
@Composable
fun Nodes(nodes: List<CommentNode>) {
LazyColumn {
items(nodes) { node ->
Node(node)
}
}
}
@Composable
fun Node(node: CommentNode) {
LazyColumn {
item {
Text(node.content)
}
item {
Nodes(node.children)
}
}
}
On the top level, LazyColumn
works, but it seems I have to use Column
for the leaves, otherwise I get an unexplained crash:
03-29 14:36:38.792 1658 6241 W ActivityTaskManager: Force finishing activity com.jerboa/.MainActivity
03-29 14:36:38.902 1658 3033 I WindowManager: WIN DEATH: Window{d3b902b u0 com.jerboa/com.jerboa.MainActivity}
03-29 14:36:38.902 1658 3033 W InputManager-JNI: Input channel object 'd3b902b com.jerboa/com.jerboa.MainActivity (client)' was disposed without first being removed with the input manager!
Has anyone had any luck building a variable length tree in jetpack compose?