我通过以下代码加载片段:
private void loadFragment(Fragment fragment) {
// load fragment
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.frame_container, fragment);
transaction.addToBackStack(null);
transaction.commit();
}
此代码不会关闭以前已加载的片段,因此,我想先关闭所有片段然后再加载新片段