CACuzcatlan
CACuzcatlan

Reputation: 5497

AlertDialog setTitle() and setMessage equivalents in FragmentDialog

I'm rewriting an existing app for Honeycomb and I've run into a problem. In the existing app, we create the an AlertDialog with default title and message values, then replace them later if needed. To replace them, we use setTitle() and setMessage():

AlertDialog dialog = getDialog();
if (some condition) {
    dialog.setTitle(R.string.error1);
    dialog.setMessage(getResources().getString(R.string.error1_msg));
}
else {
    dialog.setTitle(R.string.error2);
    dialog.setMessage(getResources().getString(R.string.error2_msg));
}

However, now that we are using DialogFragment, there is no method for setTitle() or setMessage(), so we can't change it after it has been created. Is there a workaround for this case, or are we out of luck?

Upvotes: 5

Views: 6426

Answers (1)

Spidy
Spidy

Reputation: 40002

You have to extend the DialogFragment to provide content. See the documentation for examples and other options.

Upvotes: 2

Related Questions