简体   繁体   English

如何将app.fragment与LiveData和ViewModel一起使用

[英]How can I use app.fragment with LiveData and ViewModel

I want to use ViewModelProviders.of (app.fragment) to create a ViewModel , but I find that the function of is only supported in the v4 package. 我想用ViewModelProviders.of (app.fragment)创建一个ViewModel ,但我发现,功能of在V4包只支持。 What should I do? 我该怎么办?

在此处输入图片说明

在此处输入图片说明

Do not use android.app.Fragment , the entire class is now deprecated . 不要使用android.app.Fragment整个类现在已被弃用 The support library version does everything in a much better, safer, more predictable way. 支持库版本以更好,更安全,更可预测的方式执行所有操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM