I came across a problem in dialog fragment. After opening dialogfragment 30 times, the next one blur the screen but no content. Is there a solution??
here is parent fragment:
DialogFragment newFragment = new B3Fragment();
newFragment.show(getFragmentManager(), "");
Here is my 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;
}
Thanks.
You are not creating the dialog, You must create dialog before return it.
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();
}