DialogFragment.getDialog returns null

前端 未结 5 1376
感动是毒
感动是毒 2020-12-02 16:30

I am trying to get the Dialog I have created with an extended DialogFragment using DialogFragment.getDialog() but it returns null.

5条回答
  •  悲&欢浪女
    2020-12-02 17:13

    Try calling executePendingTransactions() from the available FragmentManager.

        dialogFragment = new DialogFragment();
            ...
        dialogFragment.show(mFragmentActivity.getSupportFragmentManager(), "Dialog");
        mFragmentActivity.getSupportFragmentManager().executePendingTransactions();
    
        Dialog d = dialogFragment.getDialog()
            ...
    

提交回复
热议问题