getSupportFragmentManager()与getFragmentManager()的安卓3.0+ [英] getSupportFragmentManager() versus getFragmentManager() in android 3.0+

查看:133
本文介绍了getSupportFragmentManager()与getFragmentManager()的安卓3.0+的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在为android.support.v4.app.FragmentManager文档:

In the documentation for android.support.v4.app.FragmentManager:

静态库支持的版本用于编写在平台上运行的应用程序到Android 3.0之前,上运行时的的Andr​​oid 3.0或以上,该实现仍然使用;它不尝试切换到该框架的实施,见框架SDK文档类的概述。

"Static library support version of the framework's FragmentManager. Used to write apps that run on platforms prior to Android 3.0. When running on Android 3.0 or above, this implementation is still used; it does not try to switch to the framework's implementation. See the framework SDK documentation for a class overview."

所以,我需要做的检查在运行时,使用适当的FragmentManager的应用程序上运行的Andr​​oid版本?即调用getFragmentManager()如果在Android 3.0及更高版本,而不是getSupportFragmentManager()

So, do I need to do a check at runtime and use the appropriate FragmentManager for the android version the app is running on? i.e. call getFragmentManager() if on android 3.0+ instead of getSupportFragmentManager()

推荐答案

这没有什么错用 getSupportFragmentManager()在Android 3.0+,只要有您的支持库进口。如果你想使用 getFragmentManager()的软件开发工具包11+,去了;只要记住,你可能会的if / else 荷兰国际集团大量的code版本检查。

There's nothing wrong with using getSupportFragmentManager() on Android 3.0+ as long as you have the support library imported. If you want to use getFragmentManager() for SDKs 11+, go for it; just keep in mind that you may be if/elseing a lot of code with version checks.

这篇关于getSupportFragmentManager()与getFragmentManager()的安卓3.0+的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆