如何让DatePickerDialog继续显示方向更改?

时间:2015-09-28 04:54:24

标签: android datepicker android-edittext

我有一个在片段中成功启动的DatePickerDialog。当方向发生变化时,应用程序崩溃。 logcat输出表明NPE与DatePickerFragment的onDismiss一起发生。我在这里缺少什么?

这是部分DatePcikerFragement文件:

public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {

    public DatePickerFragment() {
    }
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
    ...
    DatePickerDialog picker = new DatePickerDialog(getActivity(),
            this, year, month, day);
    return picker;
    }


    public void onDismiss(final DialogInterface dialog) {
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(CardViewActivity.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
    super.onDismiss(dialog);
    }
}

0 个答案:

没有答案