← Android App Development (Kotlin) learning pathAndroid App Development (Kotlin) · Module 5 of 10
State and lists in Compose
Manage state and show scrolling lists.
📖 Key ideas
- var count by remember { mutableStateOf(0) } holds UI state.
- rememberSaveable survives rotation.
- State hoisting: pass value and onValueChange to make composables reusable.
- LazyColumn shows long lists efficiently.
- TextField(value, onValueChange) for input.
💡 Real-life example: State hoisting is a remote control: the parent holds the batteries (state), the child just has buttons.
rememberKeeps a value across recompositions
mutableStateOfObservable state holder
State hoistingMoving state up to the caller
LazyColumnLazy vertical list