Prompt Dialog Listener

The prompt dialog interacts with an activity through a listener callback class called PromptListener. The class has one callback method called onClick, and the button ID that is passed to onClick identifies what type of button is clicked. The rest of the code is easy to follow (see Listing 5-26). When the user enters text and clicks the OK button, the value of the text is transferred to the promptReply field. Otherwise, the value stays null.

Listing 5-26. PromptListener, the Listener Callback Class public class PromptListener implements android.content.Dialoglnterface.OnClickListener {

// local variable to return the prompt reply value private String promptReply = null;

//Keep a variable for the view to retrieve the prompt value View promptDialogView = null;

//Take in the view in the constructor public PromptListener(View inDialogView) { promptDialogView = inDialogView;

//Call back method from dialogs

0 0

Post a comment