Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 718
CACuzcatlan Avatar asked Nov 04 '22 19:11

CACuzcatlan


1 Answers

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

like image 153
Spidy Avatar answered Nov 11 '22 08:11

Spidy