可以同时选择日期和事件的控件--DateTimeWheelDia
2019-08-16 本文已影响8人
手指乐
github使用这个控件的demo地址:https://github.com/JustinRoom/WheelViewDemo
效果图:
wh.png
private DateTimeWheelDialog createDialog(int type) {
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, 1800);
calendar.set(Calendar.MONTH, 0);
calendar.set(Calendar.DAY_OF_MONTH, 1);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
Date startDate = calendar.getTime();
calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, 2120);
Date endDate = calendar.getTime();
DateTimeWheelDialog dialog = new DateTimeWheelDialog(getActivity());
// dialog.setShowCount(7);
// dialog.setItemVerticalSpace(24);
dialog.show();
dialog.setTitle("选择时间");
int config = DateTimeWheelDialog.SHOW_YEAR_MONTH_DAY_HOUR_MINUTE;
switch (type) {
case 1:
config = DateTimeWheelDialog.SHOW_YEAR;
break;
case 2:
config = DateTimeWheelDialog.SHOW_YEAR_MONTH;
break;
case 3:
config = DateTimeWheelDialog.SHOW_YEAR_MONTH_DAY;
break;
case 4:
config = DateTimeWheelDialog.SHOW_YEAR_MONTH_DAY_HOUR;
break;
case 5:
config = DateTimeWheelDialog.SHOW_YEAR_MONTH_DAY_HOUR_MINUTE;
break;
}
dialog.configShowUI(config);
dialog.setCancelButton("取消", null);
dialog.setOKButton("确定", new DateTimeWheelDialog.OnClickCallBack() {
@Override
public boolean callBack(View v, @NonNull Date selectedDate) {
//tvResult.setText(SimpleDateFormat.getInstance().format(selectedDate));
return false;
}
});
dialog.setDateArea(startDate, endDate, true);
dialog.updateSelectedDate(new Date());
return dialog;
}
@Override
protected void initEvents() {
txnamedt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
createDialog(5);
}
});
}
手机赚钱怎么赚,给大家推荐一个手机赚钱APP汇总平台:手指乐(http://www.szhile.com?from=js),辛苦搬砖之余用闲余时间动动手指,就可以日赚数百元