How to close a Dialog in Android programmatically?

Amir Hossein Ghasemi picture Amir Hossein Ghasemi · Aug 8, 2013 · Viewed 61.4k times · Source

How do I close a Dialog in android programmatically for example by a button?

Imagine I have a Dialog with a OK button on it, and want to close it by OK button, but I cant do that!

I googled and found nothing useful, and almost all of them for closing AlertDialog not a Dialog.

Answer

iagreen picture iagreen · Aug 8, 2013

You can call dismiss on the dialog.