Android 屏幕旋转后恢复对话框
我有一个对话框(来自此的材质对话框)和2个编辑文本。在我旋转后,设备活动被破坏,对话框也被破坏。我知道edittext对输入文本有自动保存功能,但我怎样才能阻止对话框被破坏呢Android 屏幕旋转后恢复对话框,android,android-alertdialog,material-design,Android,Android Alertdialog,Material Design,我有一个对话框(来自此的材质对话框)和2个编辑文本。在我旋转后,设备活动被破坏,对话框也被破坏。我知道edittext对输入文本有自动保存功能,但我怎样才能阻止对话框被破坏呢 MaterialDialog dialog = new MaterialDialog.Builder(context).customView(R.layout.dialog_edit_point_info, false) .positiveText(R.string.ok).negativeTex
MaterialDialog dialog = new MaterialDialog.Builder(context).customView(R.layout.dialog_edit_point_info, false)
.positiveText(R.string.ok).negativeText(R.string.cancel)
.positiveColorRes(R.color.dark_blue).negativeColorRes(R.color.black)
.iconRes(R.drawable.ic_marker_location)
.autoDismiss(false)
.title(R.string.edit_title_dialog).callback(callback).build;
将对话框放入DialogFragment中:
public static class MyAlertDialogFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
MaterialDialog dialog = new MaterialDialog.Builder(context).customView(R.layout.dialog_edit_point_info, false)
.positiveText(R.string.ok).negativeText(R.string.cancel)
.positiveColorRes(R.color.dark_blue).negativeColorRes(R.color.black)
.iconRes(R.drawable.ic_marker_location)
.autoDismiss(false)
.title(R.string.edit_title_dialog).callback(callback).build();
}
}
要调用对话框,请执行以下操作:
void showDialog() {
DialogFragment newFragment = new MyAlertDialogFragment();
newFragment.show(getFragmentManager(), "dialog");
}
您可以在此处找到更多信息:
如果使用支持库,请使用相应的支持类:将对话框放入对话框片段中:
public static class MyAlertDialogFragment extends DialogFragment {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
MaterialDialog dialog = new MaterialDialog.Builder(context).customView(R.layout.dialog_edit_point_info, false)
.positiveText(R.string.ok).negativeText(R.string.cancel)
.positiveColorRes(R.color.dark_blue).negativeColorRes(R.color.black)
.iconRes(R.drawable.ic_marker_location)
.autoDismiss(false)
.title(R.string.edit_title_dialog).callback(callback).build();
}
}
要调用对话框,请执行以下操作:
void showDialog() {
DialogFragment newFragment = new MyAlertDialogFragment();
newFragment.show(getFragmentManager(), "dialog");
}
您可以在此处找到更多信息:
如果使用支持库,请使用相应的支持类:请使用本说明。它可以广泛定制,以对话框片段的形式显示对话框,并可以显示从其他对话框调用的对话框 用你的这个方法。它可以广泛定制,以对话框片段的形式显示对话框,并可以显示从其他对话框调用的对话框 使用