当前位置:首页 > 开发 > 开源软件 > 正文

Android之时间和日期DatePicker和TimePicker

发表于: 2013-12-06   作者:aoyouzi   来源:转载   浏览:
摘要: 时间和日期DatePicker和TimePicker DatePicker用init指定DatePicker初始的年月日: DatePicker.init(mYear, mMonth, mDay, new DatePicker.onDateChangedListener(){ Public void onDateChanged(DatePicker view, int year, int m

时间和日期DatePickerTimePicker

DatePickerinit指定DatePicker初始的年月日:

DatePicker.init(mYear, mMonth, mDay, new DatePicker.onDateChangedListener(){

Public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth){

   mYear=year;

   mMonth= monthOfYear;

   mDay= dayOfMonth;

   //update

}});

 

TimePickersetOnTimeChangedListener()事件来处理时间改变:

TimePicker. setOnTimeChangedListener(new TinePicker.onTimeChangedListener(){

  Public void onTimeChanged(TimePicker view, int hourOfDay, int minute){

   hourOfDay= hourOfDay;

minute= minute;

   //update

}

});

 

Andriod还提供了动态修改日期和时间的APIDataPickerDialogTimePickerDialog。他们以Dialog的形式弹出显示时间。

Button.setOnClickListener(new View.onClickListener(){

Public void onCLick(view v ){

   New DatePickerDialog(classname.this, new DatePickerDialog.onDateSetListener(){

   Public void onDateSet(DatePicker view, int year, int month, int day){

   //update时间

}}, mYear, mMonth, mDay).show();}});

 

Button.setOnClickListener(new View.onClickListener(){

Public void onCLick(view v ){

   New TimePickerDialog(classname.this, new TimePickerDlalog.onTimeSetListener(){

    Public void onTimeSet(TimePicker view, int hour, int minute){

    //update

}},mHour, mMinute, true).show();

 

 

时钟对象AnalogClock

Android之时间和日期DatePicker和TimePicker

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号