Skip to content

Help with LazyList and tree structure (childs) #43

Answered by fabmax
Protoxy22 asked this question in Q&A
Discussion options

You must be logged in to vote

To make a tree, you can build a flat list of the currently visible (i.e. expanded) tree items. Whenever you collapse or expand a tree node you simply rebuild this list. The individual items in this list should have a field treeDepth which you can then use to set the margin / indent of the tree item in the lazy list.

There is a (relatively complex) Jetpack Compose example which implements a file tree this way. The file tree code is here. This is obviously Jetpack compose and not kool UI but the concept should work the same.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Protoxy22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants