how to move from one fragment to another fragment on button click

前端 未结 6 1905
失恋的感觉
失恋的感觉 2021-01-16 11:43

I am using the SherlockFragments library for the sliding menu.I have list of items as menu when I click on item fragment get opened as an activity but it is a fragment.Now

6条回答
  •  一向
    一向 (楼主)
    2021-01-16 11:49

    This is the code I use to switch fragments inside a view:

    FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
    fragmentTransaction.replace([viewId], fragment, tag);
    fragmentTransaction.addToBackStack(tag);
    fragmentTransaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    fragmentTransaction.commit();
    

提交回复
热议问题