Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getChildFragmentManager() and support libraries

I am using the getChildFragmentManager() in an app that is compiling against API level 19, with the minimum SDK set to 14.

getChildFragmentManager() was introduced in API 17, so devices running at API levels 14, 15, or 16 will throw a NoSuchMethodError when the method is called.

I did look through all the other StackOverflow questions regarding this issue, but none of them seem to answer this question: is there any way to get the getChildFragmentManager() method to work on devices pre-API level 17? If so, how?

The method does not seem to be included in either the v4 or v13 support libraries. I have tried clean builds with both v4 and v13 support libraries, but that does not seem to solve the issue.

like image 290
Mark Avatar asked May 13 '14 19:05

Mark


1 Answers

is there any way to get the getChildFragmentManager() method to work on devices pre-API level 17? If so, how?

Use the backport of fragments from the Android Support package (android-support-v4.jar, android.support.v4.app.Fragment).

The method does not seem to be included in either the v4 or v13 support libraries.

Yes, it is, on FragmentActivity, the Activity base class you need to use in order to use the fragments backport.

It is on the Fragment class from the backport, for managing child fragments of that fragment.

I have tried clean builds with both v4 and v13 support libraries, but that does not seem to solve the issue.

Either you did not change to FragmentActivity the Fragment backport, or your support library JARs are old. Here is a sample project demonstrating the use of FragmentActivity the Fragment backport and its getChildFragmentManager().

like image 160
CommonsWare Avatar answered Sep 25 '22 23:09

CommonsWare