0

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.

Kamran Taghaddos
  • 452
  • 1
  • 10
  • 22

2 Answers2

0

Maybe you should use Dialog.Builder.create() instead of new Dialog().

user4470672
  • 117
  • 5
0

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();
}
Akhilesh Dhar Dubey
  • 2,152
  • 2
  • 25
  • 39