← Android App Development (Kotlin) learning path
Android App Development (Kotlin) · Module 5 of 10

State and lists in Compose

Manage state and show scrolling lists.

📖 Key ideas

  1. var count by remember { mutableStateOf(0) } holds UI state.
  2. rememberSaveable survives rotation.
  3. State hoisting: pass value and onValueChange to make composables reusable.
  4. LazyColumn shows long lists efficiently.
  5. 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