如何禁用过去的日期?

时间:2014-12-09 10:15:32

标签: android

如何使用datepickerdialog()方法在当前日期之前停用过去日期?

public class SelectDateFragment extends DialogFragment implements
        DatePickerDialog.OnDateSetListener {
    @SuppressLint("ValidFragment")
    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {
        final Calendar calendar = Calendar.getInstance();
        int yy = calendar.get(Calendar.YEAR);
        int mm = calendar.get(Calendar.MONTH);
        int dd = calendar.get(Calendar.DAY_OF_MONTH);   

        return new DatePickerDialog(getActivity(), this, yy, mm, dd);
    }

    public void onDateSet(DatePicker view, int yy, int mm, int dd) {
        populateSetDate(yy, mm + 1, dd);
    }

}

0 个答案:

没有答案