Sign in Go Pro

Android Model-View-ViewModel Pattern

Binding the View - Binding Actions

This lesson is for PRO members.

Upgrade today to get access to all the PRO lessons.

Unlock this lesson
Autoplay

Up next

Previous

About

This lesson will teach you how to use Data Binding in your Views to bind events, such as button clicks, directly to your ViewModel.

Key concepts in this lesson that you will learn:
* How to use Data Binding in your View using the Layout Element.
* How to make use of Android Studio's quick assist features to convert existing layouts to use Data Binding.
* How to define variables in your View.
* What a Binding object is and how + when it gets created.
- You'll also learn about some of the key properties exposed by binding objects and how to use them.
* How to process events in your View and dispatch them to your ViewModel action, via lambda expressions.

Comments

I was getting databinding errors why I tried to compile this, because I'm using Android Studio 3.2 beta 5. Apparently as of Android studio 3.2, databinding no longer needs its annotation processor dependency to be declared in the gradle file. Once I removed the kapt dependency it compiled fine.

Hi Steve,

You are correct. After the Android Gradle Plugin 3.2 is released, you will no longer need to specify he kapt dependency. It will include the kapt dependency for you just by enabling data binding.

Once 3.2 is released official (not beta or RC), we'll update the lesson to reflect that.

>
You need to go PRO to post comments.

Lessons in Android Model-View-ViewModel Pattern