DialogFragment and onDismiss

前端 未结 8 1943
迷失自我
迷失自我 2020-11-27 16:14

I am using a DialogFragment, which I am showing like this from an Activity:

DialogFragmentImage dialog = DialogFragmentImage.newIns         


        
8条回答
  •  感情败类
    2020-11-27 16:42

    This is an old issue but I found no solution I am happy with. I don't like passing any Listeners to my DialogFragment or set a TargetFragment, because that may break on orientation change. What do you think about this?

            MyDialog d = new MyDialog();
            d.show(fragmentManager, "tag");
            fragmentManager.registerFragmentLifecycleCallbacks(new FragmentManager.FragmentLifecycleCallbacks() {
                @Override
                public void onFragmentViewDestroyed(FragmentManager fm, Fragment f) {
                    super.onFragmentViewDestroyed(fm, f);
                    //do sth      
            fragmentManager.unregisterFragmentLifecycleCallbacks(this);
                    }
                }, false);
    

提交回复
热议问题