//获取Frgment的管理者 FragmentManager fragmentManager = getSupportFragmentManager(); //获取事务 FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); //添加Fragment到FramLatyout中 //提交事务 fragmentTransaction.replace(R.id.home_root, new HomeFragment(), "HOME"); fragmentTransaction.replace(R.id.ment_root, new MenuFragment(), "MENU"); fragmentTransaction.commit();
//根据标示获取 MenuFragment menuFragment = (MenuFragment) fragmentManager.findFragmentByTag("MENU");
本文介绍如何使用FragmentManager和FragmentTransaction进行Fragment的添加与替换操作,并展示了如何通过findFragmentByTag方法来检索特定的Fragment实例。
307

被折叠的 条评论
为什么被折叠?



