0
我起訴在我的項目日期選取器,但我不希望將來的日期啓用選擇: -如何禁用日期選擇將來的日期在android系統
我還使用了應答中的鏈接,
Disable future dates in Android date picker
,但它不爲我工作, 我採用了android 2.2.3工作室,和我的API爲22
public void showTruitonDatePickerDialog(View v) { DialogFragment newFragment = new DatePickerFragment(); newFragment.show(getFragmentManager(), "datePicker"); } public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker final Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int day = c.get(Calendar.DAY_OF_MONTH); // Create a new instance of DatePickerDialog and return it return new DatePickerDialog(getActivity(), this, year, month, day); } public void onDateSet(DatePicker view, int year, int month, int day) { ddate.setText(day + "/" + (month + 1) + "/" + year); } }
感謝它的工作... – User8713
不客氣。 –