Complete the code to create a simple Compose text element that says "Hello World".
Text(text = [1])In Compose, text content must be a string literal or variable. The text must be in quotes to be a string.
Complete the code to create a button with a click listener in Compose.
Button(onClick = [1]) { Text("Click me") }
The onClick parameter expects a lambda function. Wrapping the function call inside curly braces creates a lambda.
Fix the error in the Compose code to display a list of items using LazyColumn.
LazyColumn {
items([1]) { item ->
Text(text = item)
}
}The items function expects a list variable. Use the variable name that holds the list, not a function call or undefined name.
Fill both blanks to create a composable function with a parameter and display it.
fun Greeting([1]: String) { Text(text = "Hello, [2]!") }
The parameter name and the variable used inside the text must match to display the passed value correctly.
Fill all three blanks to create a stateful counter button in Compose.
var count by remember { mutableStateOf([1]) }
Button(onClick = { count [2] 1 }) {
Text(text = "Clicked [3] times")
}Initialize count to 0, increment it with += 1 on click, and display the current count using $count inside the text.