One DialogFragment at the press of a button causes another DialogFragment (the first one does not close). those. in the stack we have Frag1 -> Frag2. When you rotate the screen A strange thing happens, Frag1 appears in front of your face, and behind it you can see Frag2. Those. Frag2 -> Frag1. How to do the opposite? Are there any solutions?

First dialogue:

  @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); View view = inflater.inflate(R.layout.new_category_dialog, container, false); EditText moneyET = (EditText)view.findViewById(R.id.newCategory_moneyET); EditText categoryET = (EditText)view.findViewById(R.id.newCategory_categoryET); Button colorBtn = (Button)view.findViewById(R.id.newCategory_colorBtn); Button negativeBtn = (Button)view.findViewById(R.id.newCategory_negativeBtn); Button positiveBtn = (Button)view.findViewById(R.id.newCategory_positiveBtn); DialogListener listener = new DialogListener(getFragmentManager(), getDialog(), moneyET, categoryET); colorBtn.setOnClickListener(listener); negativeBtn.setOnClickListener(listener); positiveBtn.setOnClickListener(listener); return view; } 

Second dialogue:

 @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) { getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE); View view = inflater.inflate(R.layout.color_picker_dialog, null); ColorPickerView colorPickerView = (ColorPickerView) view.findViewById(R.id.color_picker_view); Button positiveBtn = (Button) view.findViewById(R.id.color_positiveBtn); Button negativeBtn = (Button) view.findViewById(R.id.color_negativeBtn); DialogListener listener = new DialogListener(getDialog()); colorPickerView.addOnColorSelectedListener(listener); positiveBtn.setOnClickListener(listener); negativeBtn.setOnClickListener(listener); return view; } 

Class Listener:

 switch (v.getId()){ case R.id.newCategory_negativeBtn: dialog.dismiss(); break; case R.id.newCategory_positiveBtn: break; case R.id.newCategory_colorBtn: ColorPickerDialog colorDialog = new ColorPickerDialog(); colorDialog.show(fragmentManager, "colorPickerDialog"); break; // для диалога выбора цвета case R.id.color_positiveBtn: break; case R.id.color_negativeBtn: break; default: break; } 
  • one
    You would drop the code here. Something I do not think that they are in one stack. And in general, using 2 DialogFragments in this way is not a good idea. I would make Frag1 a regular fragment that calls Frag2, which is already a DialogFragment. - YungBlade
  • @CookieMnstr Updated. The point is that in the first dialog you have to click on the cube, a new dialog box with a palette appears, select the color there, click "OK" the palette dialog closes and the cube in the first dialog should be painted in the desired color. In words, everything is easy, but in fact I have no idea how to do it all. And yet, the “stack” I figuratively said, I honestly say, I have no idea how they behave, but since this is DialogFRAGMENT, then surely they are on the stack. - Ivan
  • can try to prohibit the repainting of the activity when you rotate the screen? in the application-level manifest add android: configChanges = "orientation | screenSize" - YungBlade
  • @CookieMnstr is very limiting, because The whole application is built around a single activation. - Ivan

0