我有一个min活动它有两个布局。
-----------Root Layout------------
- -
- Layout 1 -
----------------------------------
- -
- Layout2 -
----------------------------------
我使用getSupportFragmentManager
将mainActivity替换为片段,它可以正常工作。替换代码如下:
fragmentTransaction.replace(rootLayoutId, fragment);
但是我尝试将所有页面仅替换为以下特定布局:
childFragMan = fragment.getChildFragmentManager();
childFragTrans = childFragMan.beginTransaction();
childFragTrans.add(layout1ID, subFragment);
childFragTrans.addToBackStack(to);
childFragTrans.commit();
我的异常消息在这里:
java.lang.IllegalStateException: Activity has been destroyed
06-08 18:46:15.022 5290-5290/? W/System.err: at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1560)
06-08 18:46:15.022 5290-5290/? W/System.err: at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:696)
06-08 18:46:15.022 5290-5290/? W/System.err: at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:662)
06-08 18:46:15.022 5290-5290/? W/System.err: at io.smartface.plugin.SMFJSObject.callAsFunction(Native Method)
06-08 18:46:15.022 5290-5290/? W/System.err: at io.smartface.plugin.SMFJSObject.callAsFunction(SMFJSObject.java:271)
06-08 18:46:15.022 5290-5290/? W/System.err: at io.smartface.android.SFProxyInvocationHandler.handleMethodInJS(SFProxyInvocationHandler.java:40)
06-08 18:46:15.022 5290-5290/? W/System.err: at io.smartface.android.SFProxyInvocationHandler.invoke(SFProxyInvocationHandler.java:22)
06-08 18:46:15.022 5290-5290/? W/System.err: at java.lang.reflect.Proxy.invoke(Proxy.java:393)