我想显示片段对话框。但对话框没有显示出来。我不知道哪里存在问题。我也在’onCreateDialog’中创建了视图。当我编写对话框片段xml代码时是否有任何规则?如果你 …
试试这个:
void showDialog() { mStackLevel++; // DialogFragment.show() will take care of adding the fragment // in a transaction. We also want to remove any currently showing // dialog, so make our own transaction and take care of that here. FragmentTransaction ft = getFragmentManager().beginTransaction(); Fragment prev = getFragmentManager().findFragmentByTag("dialog"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); // Create and show the dialog. DialogFragment newFragment = MyDialogFragment.newInstance(mStackLevel); newFragment.show(ft, "dialog");
}
Doc: https://developer.android.com/reference/android/app/DialogFragment
尝试此解决方案
private void showDialog(String text, boolean isUpdate) { FragmentManager fm = getActivity().getSupportFragmentManager(); if (fm != null) { ReviewDialogFragment reviewDialogFragment = new ReviewDialogFragment (); reviewDialogFragment.setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Light_NoTitleBar_Fullscreen); reviewDialogFragment.show(fm, ReviewDialogFragment.class.getName()); } }