In fact, it is possible to show several fragments of the dialogue one inside the other. Z-order depends on the order of their creation.
The code below has an example of a FragmentActivity with the required behavior.
public class MyActivity extends FragmentActivity { @Override public void onCreate(Bundle savedInstanceState) { //... } public void onSave(View view) { Intent intent = getIntent(); this.setResult(RESULT_OK, intent); finish(); } public void onCancel(View view) { finish(); } public void SelectWeekDay(View view) { DialogFragment selectWeekDayFragment = new SelectWeekDayFragment(); selectWeekDayFragment.show(getSupportFragmentManager(), "WeekDayDialog"); } public class SelectWeekDayFragment extends DialogFragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.week_day_dialog, container, true); Button saveButton = (Button) view.findViewById(R.id.button_save); saveButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { CheckBox checkboxMonday = (CheckBox) getDialog().findViewById(R.id.checkBox_monday); if (!checkboxMonday.isChecked()) { DialogFragment saveErrorFragment = new SaveErrorFragment(); saveErrorFragment.show(getSupportFragmentManager(), "SaveErrorFragment"); } else { SaveToDb(); //Perform actions to store on db or what you wish dismiss(); } } }); Button cancelButton = (Button) view.findViewById(R.id.button_cancel); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); return view; } } public class SaveErrorFragment extends DialogFragment { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new AlertDialog.Builder(getActivity()) .setMessage("You must select Monday").setPositiveButton("Ok", null).create(); } } }
source share