Where is getChildFragmentManager in support library v13?

巧了我就是萌 提交于 2020-01-22 13:55:27

问题


Android support library v13 is supposed to provide support for newer APIs from Android 3.1. However, as far as I can tell there is no support for child fragments. Specifically, where is getChildFragmentManager()? The v13 support library relies on native fragments, which didn't add this method until API level 17. I have an app with minimum SDK level 14 so I should be able to use the v13 support library, but it seems I can't.

I don't want to go all the way back to the v4 support library and take on all it's weight. The v13 library is perfect otherwise.


回答1:


If you want to use nested fragments within a native Fragment. use getFragmentManager().

If you want to use nested fragments within a support library Fragment, use getChildFragmentManager().

Just found this out by accident. It works. :)




回答2:


Android support library v13 is supposed to provide support for newer APIs from Android 3.1

Not really.

However, as far as I can tell there is no support for child fragments

Correct. You cannot change existing classes from an external library in Java. android.app.Fragment already exists, therefore the library cannot add methods to Fragment.

I have an app with minimum SDK level 14 so I should be able to use the v13 support library, but it seems I can't.

You can simply not use nested fragments. Or, use the fragments backport.

I don't want to go all the way back to the v4 support library and take on all it's weight

android-support-v13.jar is larger than android-support-v4.jar.

If v13 included all of v4 then what is its purpose?

It adds some classes, like native-fragment implementations of FragmentPagerAdapter and FragmentStatePagerAdapter, that are not needed for apps who do not have native fragments, because their android:minSdkVersion is below 11.

the v13 library uses the native fragments and activities, not support fragment

android-support-v13.jar contains all of the android.support.v4 and all of the android.support.v13 classes from the SDK.




回答3:


you should just use the v4 support library fragments. then you can use nested fragments w/ api 14. There is no real downside to doing so. They are already included in the v13 support library (it includes all of v4)



来源:https://stackoverflow.com/questions/21867894/where-is-getchildfragmentmanager-in-support-library-v13

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!