You call getDialog() too early in the DialogFragmen'ts life cycle.
getDialog() simply returns the private mDialog variable from the Dialog dialog box.
When creating an instance of DialogFragment, mDialog is null, and then it is set when onCreateDialog run inside getLayoutInflater(Bundle savedInstanceState) , so you need to call getDialog after onCreateDialog .
For example, the order of some common methods is called onCreate , onCreateDialog and onCreateView , onStart . That way you can call getDialog and return it to onCreateView or onStart , but not to onCreate or onCreateDialog .
The eventough onStart is called when the Fragment is visible to the user , setting the fragment layout at this point looks great ... for example, setting the width and height using getDialog().getWindow().setLayout(..., ...); does not change the size of the fragment, but just a new set size appears.
Peter Ajtai Feb 22 '12 at 19:43 2012-02-22 19:43
source share