Implementing a water consumption tracker
The APIs that we have explored in this chapter can be helpful for most applications. To learn how we can add preference storage to a simple application, we will explore another example project. This time, we will create a tracker that can track water consumption over 1 week.
Constructing the user interface
Before we start working with data binding APIs, we will construct the basic user interface. The aim is to put today's total in large text at the top of a window, with the date below. We will follow this with the controls to add water to the current total. Under this, we will add another section that shows the values for the current week. Let's get started:
- We will start, as usual, by defining a
makeUI
function, which builds the user interface. To start, we will define the large label that will be used to show the total by setting the font to42
points, center aligning it, and using thetheme
primary color:func makeUI...