ViewModelProviders is deprecated in 1.1.0

后端 未结 22 1458
说谎
说谎 2020-12-07 09:14

Looking at the Google docs for ViewModel, they show the below sample code on how to get a ViewModel:

val model = ViewModelProviders         


        
22条回答
  •  鱼传尺愫
    2020-12-07 10:17

    I'm no expert but i have a line of code that solved my problem in Java. Hope this helps someone.

    viewModel = 
    new ViewModelProvider
    .AndroidViewModelFactory(getApplication())
    .create(ViewModel.class);
    

    As i said i would love to provide more details, but this fixed this problem for me.

提交回复
热议问题