2

如果我尝试运行以下代码,我会收到

Attempt to invoke virtual method 'void android.app.Dialog.setOnDismissListener(android.content.DialogInterface$OnDismissListener)' on a null object reference

(bottomSheetDialogFragment.getDialog().setOnDismissListener() 中的错误)

相同的代码在另一个片段中工作,所以我不知道我在这里做错了什么。

Bundle bundle = new Bundle();
BottomSheetDialogFragment bottomSheetDialogFragment = new MediaImportFragment();
bundle.putString("url", sharedText);
bottomSheetDialogFragment.setArguments(bundle);
bottomSheetDialogFragment.show(getSupportFragmentManager(), bottomSheetDialogFragment.getTag());
getSupportFragmentManager().executePendingTransactions();
bottomSheetDialogFragment.getDialog().setOnDismissListener(new DialogInterface.OnDismissListener() {
                    @Override
                    public void onDismiss(DialogInterface dialog) {
                        onResume();
                    }
                });

问候,Battlestr1k3

4

0 回答 0