Defining a Dialog

A dialog used by an activity must be defined in advance. Each dialog has a special Dialog identifier (an integer). When the showDialog() method is called, you pass in this Dialog identifier as a parameter. At that point, the onCreateDialog() method is called and must return a dialog of the appropriate type.

You must override the onCreateDialog() method of an activity and return the appropriate dialog for a given identifier. If an activity has multiple Dialog windows, the onCreateDialog() method can use a switch statement to return the appropriate Dialog window, based on the incoming parameter—the Dialog identifier.

0 0

Post a comment