Is Nested Fragment Possible?

早过忘川 提交于 2019-12-02 08:20:53

问题


I have a ViewPager contains three fragment, and I want to put 3 new fragments into the third fragment.Is that possible?

[ViewPager]
    [Fragment 1]
    [Fragment 2]
    [Fragment 3]
        [Fragment 3-1]
        [Fragment 3-2]
        [Fragment 3-3]
[ViewPager]

EDIT: I can't getChildFragmentManager() but only getFragmentManager(), I'm using android.support.v4.app:

    FragmentManager fm = getFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.add(R.layout.tools_frame5, new Plugins());
    ft.commit();

EDIT: what about Putting 3 Activities in the third Fragment, Is that possible?


回答1:


Yes, Nested fragment is possible.

You have to use getChildFragmentManager() instead of getFragmentManager() while you are working with nested fragments. For more details look into this link.

Hope this will help you....:)



来源:https://stackoverflow.com/questions/17269187/is-nested-fragment-possible

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