public class EmptyListener implements android.content.Dialoglnterface.OnClickListener {

public void onClick(DialogInterface v, int buttonId) {

You can invoke the code in Listing 5-21 by creating a menu item in your test harness and responding to it using this code:

Alerts.showAlert("Simple Sample Alert", this);

The result will look like the screen shown in Figure 5-4.

The code for this simple alert dialog is straightforward (see Listing 5-21 and the code snippet that appears after it). Even the listener part is easy to understand. Essentially, we have nothing to perform when the button is clicked. We just created an empty listener to register against the OK button. The only odd part is that you don't do a new to create the dialog; instead, you set parameters and ask the alert-dialog builder to create it.

Figure 5-4. A simple alert dialog
0 0

Post a comment