如果对话框被关闭,我想为我的背景做点什么.所以我想知道对话框是否被关闭
If the dialog is dismissed,I want to do something for my background.So I want to know if the dialog is dismissed
你可以使用 onDismissListener
http://developer.android.com/reference/android/content/DialogInterface.OnDismissListener.html
public Dialog createDialog() {
Dialog d = new Dialog(this);
d.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(final DialogInterface arg0) {
// do something
}
});
return d;
}
如果您使用的是 DialogFragment
,只需覆盖 onDismiss()
If you are using a DialogFragment
just override onDismiss()
http://developer.android.com/reference/android/app/DialogFragment.html#onDismiss(android.content.DialogInterface)
这篇关于如何知道一个对话框是否在 Android 中被关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!