简体   繁体   English

getChildFragmentManager()方法未定义

[英]getChildFragmentManager() method is undefined

I have the same issue has this post: android.support.v4.app.Fragment: undefined method getChildFragmentManager() . 我有同样的问题有这个职位: android.support.v4.app.Fragment:未定义的方法getChildFragmentManager() I need to use getChildFragmentManager() because I'm using nested fragments. 我需要使用getChildFragmentManager()因为我正在使用嵌套片段。

My problem is: the solution in the other post does not work for me: 我的问题是:另一篇文章中的解决方案对我不起作用:

  • My SDK is updated. 我的SDK已更新。
  • I got my android-support-v4 from the SDK folder. 我从SDK文件夹中获取了android-support-v4。
  • I added android-support-v4 both the my project and ABS. 我在项目和ABS中都添加了android-support-v4。

Here is my libs: 这是我的库:

在此处输入图片说明

How can I correctly use this method? 如何正确使用此方法?

Not sure if you've resolved your issue yet, but I was having the same issue and I resolved it. 不知道您是否已经解决了问题,但是我遇到了同样的问题,并且已经解决了。 The getCildFragmentManager() method is a method of the class Fragment and not FragmentActivity. getCildFragmentManager()方法是Fragment类的方法,而不是FragmentActivity类的方法。 Just because your class extends fragment activity does not mean you'll have access to this method. 仅仅因为您的类扩展了片段活动并不意味着您可以使用此方法。 What I did is I created an instance of my fragment in which I wanted to place the child fragment and invoked the method through that fragment instance. 我要做的是创建片段的实例,我想在其中放置子片段,并通过该片段实例调用方法。 There are obviously other approaches to this, but this worked for me. 显然还有其他方法,但这对我有用。

也许是您的Android清单中的内容,请查看有关最低SDK版本的android清单的页眉或页脚。

This is because by using old android.support.v4. 这是因为使用旧的android.support.v4。

once you change the latest library.it will solved I solved it by change it. 一旦您更改了最新的库,它将解决,我通过更改来解决了。 Hope it will work 希望它能工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM