Android DatePicker, TimePicker控件的使用
生活随笔
收集整理的這篇文章主要介紹了
Android DatePicker, TimePicker控件的使用
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
Android DatePicker, TimePicker控件的使用
| public?class?TimerPickerActivity extends?Activity{ ????private?DatePicker datePicker; ????private?TimePicker timePicker; ????private?static?Calendar calendar = Calendar.getInstance(); ????@Override ??????protected?void?onCreate(Bundle savedInstanceState) { ????????????super.onCreate(savedInstanceState); ????????????setContentView(R.layout.timepicker); ????????????? ????????????timePicker = (TimePicker)findViewById(R.id.timePicker1); ????????????datePicker = (DatePicker)findViewById(R.id.datePicker1); ????????????? ????????????timePicker.setOnTimeChangedListener(new?TimePicker.OnTimeChangedListener() { ????????????????? ????????????????@Override ????????????????public?void?onTimeChanged(TimePicker view, int?hourOfDay, int?minute) { ????????????????????// TODO Auto-generated method stub ????????????????????StringBuffer buffer = new?StringBuffer(); ????????????????????buffer.append(hourOfDay < 10?? "0"?+ hourOfDay:hourOfDay ); ????????????????????buffer.append(":").append(minute); ????????????????????Toast.makeText(TimerPickerActivity.this, buffer.toString(), Toast.LENGTH_SHORT).show(); ????????????????} ????????????}); ????????????? ????????????datePicker = (DatePicker)findViewById(R.id.datePicker1); ????????????int?year = calendar.get(Calendar.YEAR); ????????????int?month = calendar.get(Calendar.MONTH); ????????????int?day = calendar.get(Calendar.DAY_OF_MONTH); ????????????? ????????????datePicker.init(year, month, day, new?DatePicker.OnDateChangedListener() { ????????????????? ????????????????@Override ????????????????public?void?onDateChanged(DatePicker view, int?year, int?monthOfYear, ????????????????????????int?dayOfMonth) { ????????????????????// TODO Auto-generated method stub ????????????????????? ????????????????} ????????????}); ????} } |
?
本文轉(zhuǎn)自Work Hard Work Smart博客園博客,原文鏈接:http://www.cnblogs.com/linlf03/archive/2013/03/08/2949283.html,如需轉(zhuǎn)載請自行聯(lián)系原作者
總結(jié)
以上是生活随笔為你收集整理的Android DatePicker, TimePicker控件的使用的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 联想T460 Win10下“系统中断”C
- 下一篇: Spring Boot 中使用 MyBa