5. This work is licensed under the Apache 2.0 License
Hello Android!
Views
TextView ImageView Button
Pathway 1 Pathway 2 Pathway 3
6. This work is licensed under the Apache 2.0 License
Class and object instances
A class is like a blueprint, which contains
instructions for how to create something.
An object instance is an actual Dice that’s
created from the blueprint.
Object instance
A second object instance
A third object instance
Dice class
7. This work is licensed under the Apache 2.0 License
Let’s Play!
Editor's Notes
In Android Studio, you can also use the Android Emulator, which can emulate various Android devices on your computer. The emulator allows you to run your app and it provides almost all capabilities that a real Android device would have. If you do have a physical device and want to use it, there are also instructions in Pathway 2 to get you setup.
[Students can either use the emulator or a physical device to test their app, it’s up to personal preference.]
Lastly, in Pathway 3, you’ll learn the basic concepts of customizing the user interface of a simple app. The user interface (also known as UI) of your app includes what the app looks like and how the user interacts with it.
The layout of an app is the design or arrangement of what the user sees on the screen. In Android, a layout is made up of Views.
Here are some examples of types of Views that are provided by Android: TextView for displaying text, ImageView for displaying images, and Button to perform some action when tapped.
As you write Kotin code for your app, you’ll need to understand what classes and objects are. You can think of a class like a blueprint. It contains instructions for how to create something. From the Dice blueprint, you can create actual Dice.
More specifically, the Dice class contains details like what properties a Dice has (e.g. number of sides) and how it behaves (e.g. it can be rolled). The great advantage of having the Dice class is now you can create as many Dice object instances as you want, as shown in the diagram. It saves time from having to write all the same code over and over again. This makes your code more organized and easier to maintain.
[Optional: You could also use this analogy. A blueprint of a house contains the instructions of how to create the house. But the blueprint is not the house itself. The actual house is the object instance, and you can create multiple house object instances from the same blueprint.]
[This activity is designed for in-person meetings.]
Let’s play a game where you get to use the Dice Roller app you just created! This is a twist on a group rock paper scissors game you may have played.
Pair up and hit the Roll button on your own app at the same time.
Whoever has a higher roll, wins.
Whoever loses cheers on the winner, as they play against their next component.
If you tie, play against the same person again.
The game keeps going until there are only 2 people in the room left to play each other, with everyone else cheering each side on, until a grand winner is declared!
[If some people didn’t finish the app, that’s totally okay. They can Google “Random number between 1 and 6” and it will do the same thing.]
[If you’re meeting virtually, instead of playing the game, you can have folks share how they would extend the app by adding additional features. Or you can have them share if they thought of any future app ideas from building this one.]