‫Welcome back.
‫We created this layout.
‫We need to get the data from this edit text using the data binding and solve the equation.
‫To do that we need to add the data binding to our project.
‫So go to the Build.gradle CSS file, go to Android Sqoop and here I'll add build features and use data
‫binding equals to true.
‫And if you encounter any trouble when running the application, just change the target SDK to 34, then
‫sync the project.
‫After that, we need to change this layout to a layout in data binding.
‫So layout and the closing tag.
‫Cut it from here and paste it at the end of this file.
‫Also, don't miss to move these namespaces and add them to the layout here.
‫Okay, this is the layout tag and these are the other widgets included inside the constraint layout.
‫Here I need to define the data variables and to create a variable.
‫To associate with this edit text, I need to create a new class here named as my equation.
‫This equation class will extend from Bayes observable alt plus.
‫Enter to import the Bayes observable class from the data binding package and in uh and change it to
‫constructor invocation.
‫Bayes observable is a class provided by Android Data Binding library.
‫It's part of the Android architecture components and serves as a foundation for implementing the observer
‫pattern in the context of data binding.
‫The primary purpose of Bayes observable class is to make it easier to notify observers, such as UI
‫components when underlying data changes, facilitating automatic updates to the UI and the observer
‫pattern is a design pattern where an object known as the subject maintains a list of dependencies.
‫Observers that need to be notified of any changes to the subjects.
‫State based observable helps implement this pattern in the context of data binding, and we learned
‫about this in the two way data binding.
‫Then I'll create the variables here I'll create var a.
‫It's of type string equals to empty string var b it's of type string equals to empty string, and var
‫c it's of type string equals to empty string.
‫Also I'll create a variable of type activity.
‫Main binding equals to bind.
‫Later on I'll show you what is the purpose of using this binding object type activity main binding.
‫And I'll use late initiate and to use the Bindable annotation I need to use here in the Build.gradle
‫js file, the plugin id Kotlin Kapt sync.
‫Now.
‫Now we can use the Bindable annotation.
‫I'll use it for the three variables because I'm going to get them from edit texts.
‫At first I'll add Bindable annotation for a for variable a, and I'll use the setter method of this
‫variable.
‫A set value field equals to value.
‫This is the default setter in Kotlin.
‫Please review the setters and getters in the Kotlin basics, and I'll use a method called notify property.
‫Changed b r dot a at Bindable.
‫Annotation is used in the context of Android data binding to mark properties for which the data binding
‫library should generate code to handle change notifications.
‫When a property annotated with at Bindable changes, it triggers automatic updates in the UI that is
‫bound to that property.
‫This annotation is typically used in classes that extend base observable, and I'm using this Bindable
‫annotation to bind this variable.
‫Any change to this variable A with this edit text that it is responsible for entering a the same way
‫I'll use with b and C.
‫So at Bindable and here I'll use the setter method for b and set the value to be.
‫Then for c bindable and set the value property of c.
‫Okay.
‫This is how we bind these variables to the edit text.
‫The generated BR class is automatically generated by the data binding library.
‫Contains identifiers for all property.
‫It is marked with at bindable.
‫In your project, when the values of a property marked with at Bindable annotation changes, you should
‫manually call notify property changed method within the setter method.
‫This method is part of the base observable class, and is responsible for notifying any registered observers
‫that the property has changed.