ViewModelProviders is deprecated in 1.1.0

后端 未结 22 1475
说谎
说谎 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 09:58

    ViewModelProviders.of() has been deprecated.

    Use ViewModelProvider constructors directly as they now handle the default ViewModelProvider.Factory role.

     mainActivityViewModel = new ViewModelProvider(this).get(MainActivityViewModel.class);
    

提交回复
热议问题