‫We finished the room database repository and the view model.
‫So we finished the model and the view model sections of the Mvvm.
‫Now let's move to create our view.
‫The view represents the user interface of an application.
‫It includes everything the user can see and interact with, such as UI components, layouts, widgets
‫and screens.
‫It defines how the data from the view model is presented to the user.
‫The view handles user interactions such as button clicks, text input and gestures when a user interacts
‫with the UI.
‫The view communicates these actions to the ViewModel.
‫The View observes live data or other observable data sources provided by the View model.
‫Live data allows the view to automatically update itself when the underlying data changes, providing
‫real time updates to the user.
‫Ideally, the view should not contain business logic or data retrieval code.
‫Instead, it delegates these responsibilities to the view model.
‫The separation of concerns helps maintain code, clarity and testability.
‫So in summary, the view in an Mvvm architecture is responsible for presentation of data and user interactions.
‫While the View model manages the underlying data, business logic and the communication between the
‫model and the View.
‫So let's jump into Android studio and start building our layouts and activities.
‫Main activity.
‫Go split mode and remove this text view.
‫In this example I'll use data binding.
‫So for that I'll go to the build.gradle and here I'll add the data binding dependency or enable it inside
‫the Android scope.
‫I need to add build features data binding equal to true sync.
‫The project.
‫Now we're able to use data binding.
‫So here I'll start with layout tag and I'll move all of these.
‫Into the layout, and I'll move these namespaces to the layout here.
‫And inside this constraintlayout I'll create a recycler view and a fab floating action button.
‫Add the constraints, you can infer it.
‫Or drag and drop like this.
‫This is our recycler view.
‫I'll create a fab floating action button.
‫Wrap content.
‫And this is a small button I'll drag and drop it to here and infer the constraints ensuring that from
‫the end is 16 deep margin and from the button is 60.
‫And this is our fab floating action button.
‫It's just a simple button.
‫This will direct us to the add new contact activity.
‫Now let's move and create a new layout file.
‫I'll name it as contact underscore list item and this will be the template and the layout for every
‫contact in our application.
‫Of course I'll use the data binding.
‫So I'll start with the layout.
‫And move these and the namespaces move them to the layout.
‫And this is our constraint layout.
‫Inside this constraint layout, I'll create two text views, one for the name and one for the email
‫of the contact.
‫I'll start with the text view.
‫And this is our layout to text views.
‫I'll add margin here, 16 dpi for the whole constraint layout and the height would be wrap content.
‫So this is our contact list item template for every item in the database.