May 2022
Intermediate to advanced
688 pages
20h 12m
English
The first step is to add a ViewModel to store the List of Crime objects you will eventually display on the screen.
As you learned in Chapter 4, the ViewModel class is part of the lifecycle-viewmodel-ktx library.
So begin by adding the lifecycle-viewmodel-ktx dependency to your app/build.gradle file (that is, the build.gradle file labeled Module: CriminalIntent.app).
Listing 10.1 Adding lifecycle-viewmodel-ktx dependency (app/build.gradle)
dependencies {
...
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.fragment:fragment-ktx:1.4.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.1'
...
}
Do not forget to sync your Gradle files after ...
Read now
Unlock full access