![]() Log.i(TAG, "Put the MusicItemData list in the shared ViewModel so that it be used by the MusicListFragment to display it") Val musicListFragment = MusicListFragment() Val musicItemDataList: ArrayList? = response.body()?.results ![]() Import com.dj.Ĭlass MusicSearchActivity: AppCompatActivity() ") ![]() Implementation ":kotlin-stdlib:$kotlin_version"ĪndroidTestImplementation ':junit:1.1.2'ĪndroidTestImplementation ':espresso-core:3.3.0' Implementation ':picasso2-okhttp3-downloader:1.1.0' Implementation 'androidx.recyclerview:recyclerview:1.2.0' Implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1' Implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.3.1' Implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' Implementation 'androidx.legacy:legacy-support-v4:1.0.0' Implementation 'agment:fragment-ktx:1.3.4' Implementation 'nstraintlayout:constraintlayout:2.0.4' Implementation 'androidx.appcompat:appcompat:1.3.0' TargetCompatibility JavaVersion.VERSION_1_8 SourceCompatibility JavaVersion.VERSION_1_8 ProguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' The Ask: I need help figuring out why the music_item.xml is not getting loaded into the music_list_fragment.xml by the RecyclerView and help learning to properly use the combination of the ViewModel + LiveData + Data Binding so that when the device is rotated the data is not loss regardless of the fragment I have loaded in the activity. Now I am upgrading this app to also use LiveData and Data Binding but I am having issues loading the music_item.xml (the ViewGroup or row) that will be loaded into the RecyclerView → music_list_fragment.xml and I don’t think I am using the combination of the ViewModel + LiveData + Data Binding properly. I successfully develop an iTunes Music Search Android app using Kotlin with one activity and three fragments (search, list, and detail) using Retrofit2 to interact with iTunes Search API, Picasso to get the art image from the server into my app, RecyclerView for the list screen, and the ViewModel to allow the fragments to exchange data.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |