如何在日历中禁用日期直到android中的当前日期
editText_Date.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
// Get Current Date
final Calendar c = Calendar.getInstance();
Date dates = c.getTime();
mYear = c.get(Calendar.YEAR);
mMonth = c.get(Calendar.MONTH);
mDay = c.get(Calendar.DAY_OF_MONTH);
mDayName = new SimpleDateFormat("EEEE", Locale.ENGLISH).format(dates.getTime());
System.out.println("mDayName = "+mDayName);
DatePickerDialog datePickerDialog = new DatePickerDialog(Create_slots.this, new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
//editText_Date.setText(dayOfMonth + "-" + (monthOfYear + 1) + "-" + year); //'dd-mm-yyy'
editText_Date.setText(year + "-" + (monthOfYear + 1) + "-" + dayOfMonth); //'yyy-mm-dd'
date1 = editText_Date.getText().toString();
System.out.println("date1 = "+date1);
}
}, mYear, mMonth, mDay);
datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000);
datePickerDialog.show();
}
});
以上代码禁用了当前日期的过去日期..我想禁用日期到当前日期。需要帮助。
答案 0 :(得分:0)
解决方案:您将使用日期选择器并将代码设置如下
DatePicker datePicker = date.getDatePicker();
datePicker.setMinDate(d.getTime());
答案 1 :(得分:0)
使用此库进行日期和时间选择
from sys import platform as sys_pf
if sys_pf == 'darwin':
import matplotlib
matplotlib.use("TkAgg")
from tkinter import *
from tkinter.ttk import *
import ui
def init_UI():
main = Tk()
main.title('data2knowledge')
n = Notebook(main)
ProcessTab = Frame(n)
MergeTab = Frame(n)
LearningTab = Frame(n)
ReportTab = Frame(n)
AboutTab = Frame(n)
n.add(ProcessTab, text = "Process")
n.add(MergeTab, text = "Merge")
n.add(LearningTab, text = "Learn")
n.add(ReportTab, text = "Report")
n.add(AboutTab, text = "About")
if __name__ == '__main__':
'''initialize GUI and start it'''
gui = init_UI()
gui.mainloop()
可在此处找到文档:
您可以在此限制时间选择器或日期选择器