简体   繁体   中英

DialogFragment doesn't show when set onDismiss

mSomeFragment = new SomeFragment();
mSomeFragment.show(getFragmentManager(), "some");

The Fragment shows fine.

mSomeFragment = new SomeFragment();
mSomeFragment.show(getFragmentManager(), "some");

mSomeFragment.onDismiss(new DialogInterface() {

     @Override
     public void cancel() {
          //
     }

     @Override
     public void dismiss() {
          //
     }
});  

But when I set onDismiss , this doesn't work (the Fragment doesn't shows). I wanna do some operations when the dialog dismisses. Could you tell me why??

Calling onDismiss actually calls this code

  if (mDialog != null) {
        mDialog.dismiss();
        mDialog = null;
  }

which dismisses the dialog. If you want to listen for events on the dialog use onOptionsItemSelected()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM