我需要从片段中打开片段并使用导航抽屉。我知道用于此类事件的片段事务,但它调用抽屉,而不是特定片段。
任何帮助?
Fragment fragment= new ProfileFragment();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_navigation_drawer, fragment); // fragmen container id in first parameter is the container(Main layout id) of Activity
transaction.addToBackStack(null); // this will manage backstack
transaction.commit();
答案 0 :(得分:0)
您只能通过这种方式将子片段添加到片段中:
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
transaction.add(R.id.fragment_navigation_drawer, fragment).addToBackStack(null).commit();