Error inflating Fragment in Dialog the second time

前端 未结 6 878
深忆病人
深忆病人 2020-12-03 08:31

I have the following code in an Activity that starts a dialog for a layout that contains a fragment.

...
case R.id.pick_resource:
        dialog = new Dialo         


        
6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-03 09:03

    Another answer that could help someone else: I had a similar problem but instead of destroying the fragment in the onDestroy, I had to move it to onPause in order to get it to work:

    @Override
    protected void onPause() {
        if(adFragment != null){
            childFragmentManager.beginTransaction().remove(adFragment).commitAllowingStateLoss();
        }
        super.onPause();
    }
    

提交回复
热议问题