日期选择器
程序员文章站
2022-05-01 17:05:50
...
public void onYearMonthDayPicker(View view) {
final DatePicker picker = new DatePicker(this);
picker.setCanceledOnTouchOutside(true);
picker.setUseWeight(true);
picker.setTopPadding(ConvertUtils.toPx(this, 10));
picker.setRangeEnd(2111, 1, 11);
picker.setRangeStart(2016, 8, 29);
picker.setSelectedItem(2050, 10, 14);
picker.setResetWhileWheel(false);
picker.setOnDatePickListener(new DatePicker.OnYearMonthDayPickListener() {
@Override
public void onDatePicked(String year, String month, String day) {
showToast(year + "-" + month + "-" + day);
}
});
picker.setOnWheelListener(new DatePicker.OnWheelListener() {
@Override
public void onYearWheeled(int index, String year) {
picker.setTitleText(year + "-" + picker.getSelectedMonth() + "-" + picker.getSelectedDay());
}
@Override
public void onMonthWheeled(int index, String month) {
picker.setTitleText(picker.getSelectedYear() + "-" + month + "-" + picker.getSelectedDay());
}
@Override
public void onDayWheeled(int index, String day) {
picker.setTitleText(picker.getSelectedYear() + "-" + picker.getSelectedMonth() + "-" + day);
}
});
picker.show();
}
上一篇: 在EclipsePHP里修改代码注释
下一篇: CSS 选择器(一)