只需使用 DatePicker Dialog,当您在弹出对话框中更改方向时,它会给您一个错误。如何禁用方向更改?
public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
private Task mTask;
private static final String DIALOG_DATE = "Date";
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
int year;
int month;
int day;
final Calendar c = Calendar.getInstance();
year = c.get(Calendar.YEAR);
month = c.get(Calendar.MONTH);
day = c.get(Calendar.DAY_OF_MONTH);
return new DatePickerDialog(getActivity(), this, year, month, day);
}