Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the use of dismiss method in dialog

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report