Using Linear Layouts
The basic display on a bicycle computer includes a timer that tracks how long you’ve been riding. You will build this functionality in this section. The first step is to build a user interface that will include a Start button as well as a Stop button for the timer. The timer output will appear on the text view you have already created. To build this functionality, follow these steps.
1. Edit the existing TextView
in the activity_timer.xml
file. Remove the line that sets the android:text
attribute. (The text will no longer be hard-coded but instead will be dynamic and changed through code you will add later.)
2. Change the android:id
to the value @+id/timer
:
<TextView android:id="@+id/timer" ...
Get Learning Android™ Application Programming: A Hands-On Guide to Building Android Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.