我在对话框片段中遇到了一个问题。打开dialogfragment 30次后,下一个模糊屏幕但没有内容。有解决方案吗?
这里是父片段:
DialogFragment newFragment = new B3Fragment();
newFragment.show(getFragmentManager(), "");
这是我的onCreateDialog:
public Dialog onCreateDialog(Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_b3, new LinearLayout(getActivity()), false);
// Build dialog
Dialog builder = new Dialog(getActivity());
builder.requestWindowFeature(Window.FEATURE_NO_TITLE);
builder.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
builder.setContentView(view);
return builder;
}
感谢。
答案 0 :(得分:0)
也许您应该使用Dialog.Builder.create()
代替new Dialog()
。
答案 1 :(得分:0)
您没有创建对话框,必须在返回之前创建对话框。
public Dialog onCreateDialog(Bundle savedInstanceState) {
View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_b3, new LinearLayout(getActivity()), false);
// Build dialog
Dialog.Builder builder = new Dialog.Builder(getActivity());
builder.requestWindowFeature(Window.FEATURE_NO_TITLE);
builder.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
builder.setContentView(view);
return builder.create();
}