如何创建嵌套片段A - > B - > C
当我在片段C上时,我按下后退按钮。它立即返回A,我需要先返回B,然后A. C片段将覆盖B片段视图。有人可以指导我怎么做吗?
答案 0 :(得分:0)
尝试按如下方式调用片段:
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.content_frame, fragment);//or use add(), choose your method wisely as per your requirement.
fragmentTransaction.addToBackStack(null);//this will add frag to backstack
fragmentTransaction.commit();
希望它有所帮助。