0
0
Android Kotlinmobile~10 mins

Button composable in Android Kotlin - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a simple Button with text "Click me".

Android Kotlin
Button(onClick = [1]) {
    Text(text = "Click me")
}
Drag options to blanks, or click blank then click option'
AonClick()
B() -> Unit {}
C{}
DclickListener
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of curly braces for the lambda.
Passing a function call instead of a lambda.
2fill in blank
medium

Complete the code to display a Button with the text "Submit".

Android Kotlin
Button(onClick = {}) {
    Text([1] = "Submit")
}
Drag options to blanks, or click blank then click option'
AcontentDescription
Btext
Clabel
Dtitle
Attempts:
3 left
💡 Hint
Common Mistakes
Using contentDescription instead of text.
Using label or title which are not valid parameters here.
3fill in blank
hard

Fix the error in the Button composable by completing the onClick lambda correctly.

Android Kotlin
Button(onClick = [1]) {
    Text(text = "Press")
}
Drag options to blanks, or click blank then click option'
A{ println("Pressed") }
Bfun() { println("Pressed") }
Cprintln("Pressed")
D() -> println("Pressed")
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a function call without braces causing a syntax error.
Using incorrect lambda syntax like fun().
4fill in blank
hard

Fill both blanks to create a Button with a click action that prints "Clicked" and text "Tap me".

Android Kotlin
Button(onClick = [1]) {
    Text(text = [2])
}
Drag options to blanks, or click blank then click option'
A{ println("Clicked") }
B"Tap me"
C"Click me"
D() -> println("Clicked")
Attempts:
3 left
💡 Hint
Common Mistakes
Using parentheses instead of curly braces for the lambda.
Passing the wrong string to the Text composable.
5fill in blank
hard

Fill all three blanks to create a Button with onClick printing "Hello", text "Go", and a Modifier to add padding.

Android Kotlin
Button(onClick = [1], modifier = [2]) {
    Text(text = [3])
}
Drag options to blanks, or click blank then click option'
A{ println("Hello") }
BModifier.padding(16.dp)
C"Go"
DModifier.fillMaxWidth()
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to use curly braces for the lambda.
Using the wrong Modifier function.
Not putting the text string in quotes.