如何解决这个问题, 我正在使用Google兼容性库来管理Fragment。在log cat中出现了以下错误,其中MainMenuScreen是一个FragmentActivity。
java.lang.IllegalStateException: Activity has been destroyed
at android.support.v4.app.FragmentManagerImpl.enqueueAction(FragmentManager.java:1314)
at android.support.v4.app.BackStackRecord.commitInternal(BackStackRecord.java:541)
at android.support.v4.app.BackStackRecord.commit(BackStackRecord.java:525)
我正在尝试从一个位于FragmentActivity中的片段中调用一个方法,代码如下:
MainMenuScreen objMain= new MainMenuScreen();
if(SharedVariables.isTablet){
objMain.showFragment();}else{....}
在MainMenuScreen中,该方法为:
public void showTrafficCasesDetails(){
detailsFragmentRoot.setVisibility(View.VISIBLE);
DetailsFrag detailsFrag=new DetailsFrag ();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.replace(R.id.mainScreenDetailsFrame, detailsFrag);
transaction.commit();
}