Android with Compose
Build a small screen with composable functions and state.
What you will be able to do
- Use @Composable functions for UI.
- Use remember { mutableStateOf(...) } for state.
- Hoist state to the caller for reuse.
- Preview components in Android Studio.
In plain English
Jetpack Compose describes UI with functions. State drives recomposition: remember and mutableStateOf hold local state, and state hoisting keeps components reusable.
@Composable
fun Counter() {
var count by remember { mutableStateOf(0) }
Column(modifier = Modifier.padding(16.dp)) {
Text("Clicked $count times")
Button(onClick = { count += 1 }) {
Text("Increment")
}
}
}Your turn
EasyHold local state
Create a remembered mutable state for a counter.
KOTLIN · starter
var count =Check your understanding before moving on.
Knowledge checkQuestion 1
What triggers recomposition in Compose?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.