/**
* 这段可以解决fragment嵌套fragment会崩溃的问题
*/
@Override
public void onDetach() {
super.onDetach();
try { //参数是固定写法
Field childFragmentManager = Fragment.class.getDeclaredField("mChildFragmentManager");
childFragmentManager.setAccessible(true);
childFragmentManager.set(this, null);
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}