[英]Alternative for deprecated ViewModelProviders?
According to that Medium article here, I am using the ViewModelProviders
accordingly: 根据这里的 Medium 文章,我相应地使用了
ViewModelProviders
:
myViewModel = ViewModelProviders.of(this, this.viewModeFactory).get(MyViewModel::class.java)
deprecated for me currently:目前对我来说已弃用:
@deprecated Use the 'by viewModels()' Kotlin property delegate or @link ViewModelProvider#ViewModelProvider(ViewModelStoreOwner)}, passing in the fragment.
In that article ViewModels with possible constructor arguments have a workaround where it implements the ViewModelProvider.Factory
and its overridden function override fun create(//..)
to provide different ViewModel arguments in a Map with Dagger. In that article ViewModels with possible constructor arguments have a workaround where it implements the
ViewModelProvider.Factory
and its overridden function override fun create(//..)
to provide different ViewModel arguments in a Map with Dagger.
Since I would like to learn modern technologies, I am looking for some examples with the proposed solutions?由于我想学习现代技术,我正在寻找一些建议解决方案的例子?
use this用这个
myViewModel = ViewModelProvider(this, this.viewModeFactory).get(MyViewModel::class.java)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.