1. 程式人生 > >fragment中新增fragment與activity中新增fragment的不同

fragment中新增fragment與activity中新增fragment的不同

activity中新增fragment

FragmentTransaction transaction=getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_container,rentFragment).commit();

或者transaction.add(R.id.fragment_container,rentFragment).show.commit();

fragment中新增fragment

FragmentManager manager = getChildFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();

// 把碎片新增到碎片中
 transaction.replace(R.id.llContainerfragment, fragment);
transaction.commit();