Android Fragment替换View
在BaseActivity 中添加替换方法
public void replace(int id, Fragment fragment) {
getSupportFragmentManager()
.beginTransaction()
.replace(id, fragment)
.commitAllowingStateLoss();
}
在Activity中 调用此方法
replace(id, Fragment.newInstance());
这样就好了,简单吧