Monday, 9 February 2015

How to use Dialogs in Android ?

* Dialogs in Android are asynchronous, which provides flexibility.

* However, if you are accustomed to a programming framework where dialogs are primarily synchronous ( such as Microsoft Windows, or JavaScript dialogs in web pages ), you might find asynchronous dialogs a bit unintuitive.

* With a synchronous dialog, the line of code after the dialog is shown does not run until the dialog has been dismissed.

* This means the next line of code could interrogate which button was pressed, or what text was typed into the dialog.

* In Android however, dialogs are asynchronous. As soon as the dialog has been shown, the next line of code runs, even though the user hasn't touched the dialog yet.

* Your application has deal with this fact by implementing callbacks from the dialog, to allow the application to be notified of user interaction with the dialog.

* This also means your application has the ability to dismiss the dialog from code, which is powerful.

* If the dialog is displaying a busy message because your application is doing something, as soon as your application has completed that task, it can dismiss the dialog from code.

No comments:

Post a Comment