error: cannot find symbol
MainActivityViewModel model = ViewModelProvider(this).get(MainActivityViewModel.class);
I tried different solutions available but no luck for me.
error: cannot find symbol
MainActivityViewModel model = ViewModelProvider(this).get(MainActivityViewModel.class);
I tried different solutions available but no luck for me.
Copyright © 2021 Jogjafile Inc.
You can create a view model using the
by ViewModels()kotlin property delegate:or you can use
ViewModelProviderto create ViewModels and retain them in a store of the givenViewModelStoreOwner.Check the official documentation for best practices: https://developer.android.com/reference/androidx/lifecycle/ViewModelProviders#of(androidx.fragment.app.Fragment) https://developer.android.com/reference/androidx/lifecycle/ViewModelProvider#ViewModelProvider(androidx.lifecycle.ViewModelStoreOwner)