Android 日期对话框 DatePickerDialog
程序员文章站
2022-04-21 16:38:14
private int year; private int monthOfYear; private int dayOfMonth; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(saved... ......
private int year; private int monthofyear; private int dayofmonth; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); button = (button) findviewbyid(r.id.button); calendar calendar = calendar.getinstance(); year = calendar.get(calendar.year); monthofyear = calendar.get(calendar.month); dayofmonth = calendar.get(calendar.day_of_month); button.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub datepickerdialog pickerdialog = new datepickerdialog(mainactivity.this, new ondatesetlistener() { @override public void ondateset(datepicker view, int year, int monthofyear, int dayofmonth) { // todo auto-generated method stub toast.maketext(mainactivity.this, year + "年" + monthofyear + "月" + dayofmonth + "日", 1).show(); } }, year, monthofyear, dayofmonth); pickerdialog.show(); } }); }
上一篇: JavaScript—点击事件的写法
下一篇: React入门学习
推荐阅读
-
Android中创建一个透明的进度对话框实例
-
Android开发之PopupWindow创建弹窗、对话框的方法详解
-
Android 对话框dialog使用注意点(android.view.WindowManager$BadTokenException)
-
Android实现单选与多选对话框的代码
-
详解Android中提示对话框(ProgressDialog和DatePickerDialog和TimePickerDialog&PopupWindow)
-
很实用的Android日期计算类
-
实例详解Android自定义ProgressDialog进度条对话框的实现
-
Android 自定义ProgressDialog进度条对话框用法详解
-
android实现双日期选择控件(可隐藏日,只显示年月)
-
Android仿IOS底部弹出对话框