Skip to content

A simple Dice Roller App with button using random inbuilt function.

License

Notifications You must be signed in to change notification settings

HemantSachdeva/DiceRoller

Repository files navigation

Create a Dice Roller App with Button

Code for the Android Basics in Kotlin: Create a Dice Roller app codelab.

In this codelab, you will create a Dice Roller Android app where users can click a Button in the app to roll a dice. The outcome of the roll will be shown in a TextView on the screen.

You will use the *Layout Editor in Android Studio to build your app layout, and then write Kotlin code for what happens when the Button is clicked.

Prerequisites

  • How to create and run a "Hello, World!" app in Android Studio.
  • Familiar with using TextViews in an app.
  • How to modify the attributes of a TextView in the Layout Editor.
  • How to extract text into a string resource to make it easier to translate your app and reuse strings.
  • Kotlin programming basics

What you'll learn

  • How to add a Button to an Android app.
  • How to add behavior for when a Button is tapped in the app.
  • How to open and modify the Activity code of an app.
  • How to display a Toast message.
  • How to update the contents of a TextView while the app is running.

What you'll build

A Dice Roller Android app that has a Button to roll a dice and updates the text on the screen with the result of the roll.

What you need

A computer with Android Studio installed.

Here is what the app will look like when you have completed this codelab.

DiceRollerOutput1 DiceRollerOutput2