根据片段生命周期,我想:
- Add fragment A + addToBackStack(null)
|
- Add fragment B + addToBackStack(null)
当我从BI按回来时,期望Oncreateview应按照生命周期进行调用,但看起来似乎:它只是弹出后台,但没有一种方法是调用。所以如何识别片段A中的反压?
这是我简单的代码格式:
// I am calling fragment like this way
Fragment fragmentb=new FragmentB();
FragmentManager fragmentManager=getFragmentManager();
FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction();
fragmentTransaction.add(R.id.fragment,fragmentb).addToBackStack(null);
fragmentTransaction.commit();
答案 0 :(得分:0)
Fragment fragmentb=new FragmentB();
FragmentManager fragmentManager=getFragmentManager();
FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.fragment,fragmentb);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();