如何摆脱这个, 我正在为Fragments使用Google兼容性库。我在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();
}
答案 0 :(得分:1)
解决了......
MainMenuScreen objMain=(MainMenuScreen)getActivity(); if(SharedVariables.isTablet){
objMain.showFragment();}