Binding data to views in Android can be an exercise in redundancy. We have typed the methods 'findViewById' and 'setText' many times and have consigned ourselves to the monotony. At Google I/O 2015, a new data binding library was announced that promises to free us from much of the boilerplate code we write for our views. Even in its beta release, the library is powerful and useful. The Data Binding Guide provided by Google teases the capabilities of this library. This course will explore the details of the data-binding library mixing both theory and practice. After finishing the course, you will have a solid foundation on how to use the data binding library to reduce your development time and increase your code clarity.
Richard is a Senior Software Developer for Vertigo Software. He takes a holistic approach toward software development by exploring pan-technological and non-technological solutions to customer issues. Richard blogs about code and technology at http://elegantcode.com/author/rcirerol.
Observables Welcome back to Android Fundamentals: Data Binding. So far we've introduced the Data Binding Library and started using the built-in binding adapters. We also discussed how to create custom binding adapters, how to bind event listeners, and how to bind variables dynamically. In this module, we will explore another set of classes that are included with the data binding library, observables. Before diving in, I want to introduce the roadmap for this module. First, we will look at a common pattern that is used in Android programming, the listener or mediator pattern. We'll see how data binding encapsulates that code for us. Then we'll look at the observer pattern. We'll look at the differences between data binding's implementation of the mediator pattern and the observer pattern. And after that, we'll take the same journey through some code. We now have a roadmap. Let's get started.
Pitfalls and Pro-tips Welcome back to Android Fundamentals: Data Binding. We have gone through nearly every piece of the Data Binding library, but before we finish up, I want to point out a few pitfalls that I have found, and I also want to show you a couple of pro tips and patterns that I have come across since I started using the library. If you're like me, you're always on the lookout for some good libraries to use in your projects. Many libraries use annotation processing, and some library authors depend on an annotation processor called apt. So when using apt along with the Data Binding Library, you need to remember to add the apt directive to the dependency's closure of your build. gradle file. And then, when you're looking for your sources, they're no longer in the build/intermediates folder. The classes will be there, but the Java files will not. The generated Java files are created in the build/generated/source/apt folder.