All days
Day 08Module 4 · Architecture Components· 4–6 hrs
Architecture II — Data Binding, MVVM, LiveData, Safe Args
Finish the BMI Calculator using MVVM: ViewModel holds state, LiveData notifies the UI, Data Binding removes findViewById, and Safe Args replaces Bundle string keys.
0% done
Key concepts
- MVVM separation (View / ViewModel / Model)
- ViewModel survives configuration changes
- LiveData & observe
- Data Binding (<layout> tag)
- Safe Args plugin
Lectures in this day
- 01
Introducing Data Binding
Data Binding lets your XML layout know about your Kotlin values directly, so you don't have to write `findViewById` for every view. After you turn it on in Gradle, Android Studio makes a typed `Binding` class from your layout.
Real life · A voice-controlled remote: instead of hunting for the right button, you just say the name of the thing you want.gradle// build.gradle (Module: app) android { buildFeatures { dataBinding = true } // turn it on }Practice · 3 quick questions
Q1.Data Binding lets you…
Q2.It's enabled in…
Q3.Layouts using it start with…
Pick one answer per question. - 02
Introducing MVVM and ViewModel
MVVM is a way to organize your code into 3 layers. Model = your data. View = the screen you see. ViewModel = the brain that holds the state and does the logic. The ViewModel survives when you rotate the phone, so nothing is lost.
Real life · In a restaurant, waiters (screens) change shifts, but the chef's prep station (ViewModel) stays the same all day.kotlinclass BmiViewModel : ViewModel() { var bmi: Float = 0f private set 0