Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the use of dismiss method in dialog

Shulou Source: shulou.com Published: 2022-06-03 11:02:37 09月12日 Update

Editor to share with you what is the use of the dismiss method in dialog, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Dismiss: probably just delete the view, call the Onstop callback, and set mShowing to false. It is recommended to use dismiss, which is one less judgment than cancel, which is generally sufficient, of course, if you have a CancelListener, then use cancel.

Dialogdismiss coding

VoiddismissDialog () {

If (mDecor==null | |! mShowing) {

Return

}

If (mWindow.isDestroyed ()) {

Log.e (TAG, "TriedtodismissDialog () buttheDialog'swindowwasalreadydestroyed!")

Return

}

Try {

MWindowManager.removeViewImmediate (mDecor)

} finally {

If (mActionModekeeper null) {

MActionMode.finish ()

}

MDecor=null

MWindow.closeAllPanels ()

OnStop ()

MShowing=false

SendDismissMessage ()

}

Android dialog disappears: dismiss, cancel, hide

In our opinion, the effect of dismiss is the same as that of cancel, but from the point of view of the source code, dismiss is called in cancel, and you can listen to cancelListener if you call cancel.

Dismiss can be in any thread and the dialog object is destroyed.

Hide only hides the dialog box and does not destroy it. If you plan to use this method to destroy the dialog box, there will be a problem, and the crash log will appear when the Activity is destroyed, because when the Activity is destroyed, you need to close the dialog box. As you can see from the source code, hide just hides view. (gone).

The above is all the content of the article "what is the use of the dismiss method in dialog". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Dialog boxes articles dialogs methods content source code generally speaking not much enough most of the objects that is suggestions effects logs time more knowledge threads coding Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information NVidia OPPO Reno Linux macOS