‫Let's continue with the view of the mvvm.
‫And in this video I'll add the data binding variables of the layouts.
‫So inside the contact list item, I'll add a new variable here of type contacts that we created.
‫And this is the modal class or the entity class of our database.
‫So I'll start with the data and remember you need to place it under the layout element and before any
‫other layout the data here I start with a variable and the name would be contact and the type come master
‫coding.
‫This is the package and select the contacts class.
‫Now I need to refer the contact and get the contact name and email from this variable.
‫So for that I'll scroll down to here and instead of using name I'll add syntax of data binding.
‫And here I'll set the contact dot name the same way.
‫I'll scroll down at contact dot email.
‫It's very simple guys, and we talked about it in details in the data binding section.
‫We finished this layout.
‫Let's move to the main activity layout and I'll add a click event and handle the click events on this
‫fab, this floating action button.
‫For that, I'll create here data and I'll start with the variable.
‫The name would be click handler and the type would be a new class that I will create here, create a
‫new Java class.
‫I'll name it as main activity Click handlers.
‫When using data bindings and you have many classes you can name main activity.
‫This is referring for the main activity and the click handlers.
‫This class will act as a click handler for the main activity, so all the clicks on the main activity
‫user interface will be captured and handled here.
‫I'll start with a context context.
‫I need to pass the context from the main activity and I'll create a constructor having the context and
‫I'll create a new method called on Fab.
‫I need to pass a view.
‫Don't miss to pass the view object in the data binding in order to handle all the click events on the
‫View.
‫And here I'll start with the intent I equal to new intent and I'll set main activity dot this or get
‫application context and add new contact activity dot class and context dot start activity.
‫I'll pass the intent.
‫Let's create this activity project.
‫New activity, empty views activity and I'll name it as add new contact activity finish and this is
‫our new activity.
‫Then move back to the activity.
‫Underscore main dot XML and here I need to specify the type com dot master coding and here I'll specify
‫main activity.
‫Click handlers scroll down to the fab.
‫On.
‫Click and select this method and click handlers at Click Handler, dot on Fab Click.
‫And we talked about this operator that refers to the methods in the data binding.