The abstract class ManagedActivityDialog provides the common implementation for all the dialog classes wanting to implement the IDialogProtocol interface. It leaves the create and prepare functions to be overridden by the base classes, but provides implementations for the rest of the IDialogProtocol methods. ManagedActivityDialog also informs the parent activity that the dialog has finished after responding to a button-click event. It uses the template-hook pattern and allows the derived classes to specialize the hook method onClickHook. This class is also responsible for redirecting the show() method to the parent activity, thereby providing a more natural implementation for show(). You should use the ManagedActivityDialog class as the base class for all your new dialogs (see Listing 5-29).
Listing 5-29. The ManagedActivityDialog Class public abstract class ManagedActivityDialog implements IDialogProtocol ,android.content.DialogInterface.OnClickListener
private ManagedDialogsActivity mActivity; private int mDialogId;
public ManagedActivityDialog(ManagedDialogsActivity a, int dialogId)
mActivity = a; mDialogId = dialogId;
public int getDialogId()
public void show()
public void onClick(DialogInterface v, int buttonId)
Was this article helpful?