Designing a Prompt Dialog

Now that you've successfully created a simple alert dialog, let's tackle an alert dialog that's a little more complex: the prompt dialog. Another JavaScript staple, the prompt dialog shows the user a hint or question and asks for input via an edit box. The prompt dialog returns that string to the program so it can continue. This will be a good example to study because it features a number of facilities provided by the Builder class and also allows us to examine the synchronous, asynchronous, modal, and nonmodal nature of Android dialogs. Here are the steps you need to take in order to create a prompt dialog:

1. Come up with a layout view for your prompt dialog.

2. Load the layout into a View class.

3. Construct a Builder object.

4. Set the view in the Builder object.

5. Set the buttons along with their callbacks to capture the entered text.

6. Create the dialog using the alert-dialog builder.

7. Show the dialog.

Now we'll show you the code for each step.

0 0

Post a comment