0Pricing
Android Academy · Lesson

Buttons and Clicks

Add interactive buttons.

What Is a Button?

A Button is a tappable composable. When the user taps it, your app runs some code.

Buttons need an onClick action and content to show, usually a Text label.

Button(onClick = { }) {
    Text("Tap me")
}

The onClick Lambda

The onClick parameter takes a lambda, which is code inside curly braces { }. That code runs each time the button is pressed.

You can put any logic there, like printing or changing data.

Button(onClick = {
    println("Clicked!")
}) {
    Text("Click")
}

All lessons in this course

  1. Styling Text
  2. Buttons and Clicks
  3. Spacing with Padding
  4. Colors and MaterialTheme
← Back to Android Academy