I am trying to set the title of a DialogFragment from the onActivityCreated method of a Fragment extending ListFragment.
public void onActivityCreated(Bundle savedState) {
    super.onActivityCreated(savedState);
    ListView lv = this.getListView();
    lv.setOnItemLongClickListener(new OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1,
                int pos, long id) {
            android.app.FragmentManager fragmentManager = getFragmentManager();
            FragmentTransaction fragmentTransaction = fragmentManager
                    .beginTransaction();
            RatingDialogFragment newFragment = new RatingDialogFragment();
            newFragment.getDialog().setTitle("String");
            fragmentTransaction.add(newFragment, "dialog");
            newFragment.show(fragmentTransaction, "dialog");
            return true;
        }
    });
}
This produces a null pointer exception because the DialogFragment's mDialog is still null.
See: DialogFragment.getDialog returns null
Any ideas on how to fix this?