Android的兼容性包不包括Activity.getFragmentManager() [英] Android Compatibility Package doesn't include Activity.getFragmentManager()

查看:124
本文介绍了Android的兼容性包不包括Activity.getFragmentManager()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始尝试片段添加到我的Andr​​oid应用程序,这是基于2.1,使用刚出来3月3日在Android兼容包。我包括库到我的项目,并开始移动从我的活动为基础的类code到基于片段的一个,但我注意到,从谷歌的片段例子似乎依赖于一个事实,即在3.0 Activity类(蜂窝)有新的方法getFragmentManager()。这似乎是一个整体勾入片段的系统。

I started trying to add fragments to my Android app, which is based on 2.1, using the Android Compatibility Package that just came out on March 3rd. I included the library into my project, and started moving the code from my Activity-based class to a Fragment-based one, but I noticed that the Fragment examples from Google seem to rely on the fact that the Activity class in 3.0 (Honeycomb) has the new method getFragmentManager(). It seems to be an integral hook into the Fragment system.

我试图寻找该兼容包库里面包含的一些活动的实施,有getFragmentManager(),但我不能找到它。有谁知道在哪里可以找到getFragmentManager()这样我就可以包括片段的蜂窝兼容,如果不这样做,你知道我可以包括片段,而无需使用FragmentManager?

I've tried to look inside the Compatibility Package library for some included Activity implementation that has getFragmentManager(), but I can't find it. Does anyone know where I can find getFragmentManager() so I can include Fragments for Honeycomb compatibility, or if not do you know how I can include Fragments without using a FragmentManager?

推荐答案

您将需要扩展 FragmentActivity ,而不是正常活动。然后,你就可以调用 getSupportFragmentManager()它的工作方式相同 getFragmentManager()

You will need to extend FragmentActivity instead of the normal Activity. Then you will be able to call getSupportFragmentManager() which works the same way as getFragmentManager().

这篇关于Android的兼容性包不包括Activity.getFragmentManager()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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