//判断程序奔溃先移除掉以前的fragment 放到setContentView后
List<Fragment> fragments = getSupportFragmentManager().getFragments();
if (fragments != null) {
for (Fragment fragment : fragments) {
getSupportFragmentManager().beginTransaction().remove(fragment).commitAllowingStateLoss();
}
}
网友评论