gpt4 book ai didi

android - java.lang.IllegalStateException : while calling a method from a fragment 错误

转载 作者:太空狗 更新时间:2023-10-29 14:28:52 25 4
gpt4 key购买 nike

如何摆脱这个,我正在为 Fragments 使用 Google 兼容性库。我在日志猫中有以下错误。其中 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 中的 fragment 调用一个方法,如下所示

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();
}

最佳答案

解决了...

MainMenuScreen objMain=(MainMenuScreen)getActivity(); if(SharedVariables.isTablet){

objMain.showFragment();}

关于android - java.lang.IllegalStateException : while calling a method from a fragment 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8951171/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com