FragmentTransaction is not allowed to be added to back stack?

前端 未结 4 1978
迷失自我
迷失自我 2021-01-22 21:18

why cant my fragments be added to back stack?

@Override
    public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) {
        FragmentTransaction          


        
4条回答
  •  终归单人心
    2021-01-22 22:13

    Im not getting why you are instantiating a new FragmentTransaction inside your function, just use the one passed as a parameter. I didnt test this, but im pretty sure that it should work.

    @Override
    public void onTabSelected(Tab tab, android.app.FragmentTransaction ft) {
            ListFragment newListFragment = new bListFragment();
            Fragment newFragment = new EntryFrag();
            ft.replace(R.id.frameOne, newListFragment);
            ft.replace(R.id.frameTwo, newFragment);
            ft.addToBackStack(null);
            ft.commit();
    }
    

提交回复
热议问题