Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
376 views
in Technique[技术] by (71.8m points)

android - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...