I'm playing around with Dialog to create some quick views in my app (like login enter name etc)
and I'm wandering what is better: hide or dismiss.
I know what they both do but I keep wandering if it is better to just hide a Dialog and show it again when I need or to dismiss it and recreate it.
my Dialogs are small and are actually static in my code so as such I don't hold tons of instances.
So can somebody give me the pros and cons of using hide over dismiss.
Dialogs are normally used for notifications that should interupt the user and to perform short tasks that directly relate to the application in progress (such as a progress bar or a login prompt). The Dialog class is the base class for creating dialogs. However, you typically should not instantiate a Dialog directly.
A dialog is a small window that prompts the user to make a decision or enter additional information. A dialog does not fill the screen and is normally used for modal events that require users to take an action before they can proceed.
hide()
could cause a Leaked Window
error.If you choose to use hide()
and you exit your application using finish()
, this will cause an error message (seen here) about a window being leaked.
So, either dismiss()
your dialogs properly before calling finish()
or just use dismiss()
instead of hide()
.
It depends on how many time your need it, and if it is expensive to create it. If it is not too expensive to create it, I would personally prefer to dismiss it, to have a "cleaner environment". But if you're not using hundreds of dialogs, I don't think this really matters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With