Android Compatibility Package doesn't include

2020-05-12 04:38发布

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.

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?

3条回答
We Are One
2楼-- · 2020-05-12 05:12

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().

查看更多
男人必须洒脱
3楼-- · 2020-05-12 05:20

For people trying to make this work with Google Maps SDK see getFragmentManager with API8 and remember to update your layout file too!

查看更多
Ridiculous、
4楼-- · 2020-05-12 05:28

You have only to change your Android Target to API Level = 12

查看更多
登录 后发表回答