Recall & Review
beginner
What is a Button composable in Jetpack Compose?
A Button composable is a clickable UI element in Jetpack Compose that triggers an action when pressed. It is used to create buttons in Android apps with declarative UI.
Click to reveal answer
beginner
How do you create a simple Button with text "Click me" in Jetpack Compose?
Use the Button composable with a lambda for onClick and a Text composable inside it:
Button(onClick = { /* action */ }) {
Text("Click me")
}
Click to reveal answer
beginner
What parameter must you always provide to a Button composable?
You must always provide the onClick parameter, which is a lambda function that defines what happens when the button is pressed.
Click to reveal answer
intermediate
How can you customize the colors of a Button in Jetpack Compose?
You can customize colors by using the colors parameter with ButtonDefaults.buttonColors(), for example:
Button(
onClick = { },
colors = ButtonDefaults.buttonColors(containerColor = Color.Red)
) { Text("Red Button") }
Click to reveal answer
intermediate
What is the difference between Button and TextButton in Jetpack Compose?
Button has a background and elevation by default, making it look like a raised button. TextButton is a button without background or elevation, appearing as just text that is clickable.
Click to reveal answer
Which parameter is required when creating a Button composable?
✗ Incorrect
The onClick parameter defines the action when the button is pressed and is required.
How do you add text inside a Button composable?
✗ Incorrect
Button composable takes a lambda where you can place child composables like Text.
What does ButtonDefaults.buttonColors() help you do?
✗ Incorrect
ButtonDefaults.buttonColors() provides color customization options for buttons.
Which composable looks like a flat text without background by default?
✗ Incorrect
TextButton is a button styled as flat text without background or elevation.
What happens if you omit the onClick parameter in a Button composable?
✗ Incorrect
onClick is a required parameter; omitting it causes a compilation error.
Explain how to create a basic Button composable with a click action and text label.
Think about how you tell the button what to do and what it shows.
You got /3 concepts.
Describe ways to customize the appearance of a Button in Jetpack Compose.
Colors and styles can be changed using built-in helpers.
You got /4 concepts.