20. Data Binding and MVVM
In GeoQuiz and CriminalIntent, you used the standard Android tools to build out your app: a model
you built with Java objects, the view hierarchy, and controller objects – activities and fragments. And
in those projects, this MVC architecture was good.
In this project, you will learn how to use a tool called data binding. Data binding is just a tool – it
has no opinions about how you use it. We have opinions, though, so we will be showing you how we
like to use data binding: to implement an architecture called Model-View-ViewModel, or MVVM. In
addition, you will see how to use the assets system to store a sound file.
This chapter also starts a new application, BeatBox (Figure 20.1). BeatBox is not a box for musical
beats. It is a box that helps you beat people up. It does not help with the easy part, though: the part
where you wave your arms around dangerously, bruising and hurting another human being. It helps
with the hard part: yelling in a manner calculated to frighten your opponent into submission.
Figure 20.1 BeatBox at the end of this chapter