This course will be retired on July 14, 2025.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
- Accessing Views in Code: Declaring Variables 5:20
- Accessing Views in Code: Assigning Variables 6:24
- Initializing a Button 1 objective
- Making a Button Do Something 4:35
- Adding the OnClick Method 2:36
- Android Programming Basics 5 questions
- Generating a Random Number 4:08
- Choosing a Random Fact 4:52
- Using the Random Class 4 objectives
Well done!
You have completed Build a Simple Android App with Java!

- 2x 2x
- 1.75x 1.75x
- 1.5x 1.5x
- 1.25x 1.25x
- 1.1x 1.1x
- 1x 1x
- 0.75x 0.75x
- 0.5x 0.5x
In this video we'll see how to make a button trigger some code by adding an OnClickListener. Listeners like this sit patiently in the background and "listen" for something to happen. And when that something happens, they run their code.
Documentation
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up-
Basel Kanaan
4,458 Points6 Answers
-
sebbe12
4,015 PointsWhy do he declear TexView before using it instead of declearing it at the time when used. Less code feels better
Posted by sebbe12sebbe12
4,015 Points2 Answers
-
Michał Juszczuk
885 Points3 Answers
-
PLUS
hamza razzak
Courses Plus Student 1,342 Points1 Answer
-
Linus Karlsson
7,402 Points1 Answer
-
Elvis Chitsungo
1,817 Points2 Answers
View all discussions for this video
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up