选择对话框 android_Android日期时间选择器对话框

选择对话框 android

Android Date Time picker are used a lot in android apps. In this tutorial we’ll demonstrate the use of a Date Picker and Timer Picker Dialog in our android application. These components are used to select date and time in a customised user interface. We will use DatePickerDialog and TimePickerDialog classes with Calendar class in our android application code to achieve this.

Android日期时间选择器在android应用程序中经常使用。 在本教程中,我们将演示在Android应用程序中如何使用日期选择器计时器选择器对话框。 这些组件用于在自定义的用户界面中选择日期和时间。 我们将在Android应用程序代码中将DatePickerDialogTimePickerDialog类与Calendar类一起使用,以实现此目的。

Android DatePickerDialog和TimePickerDialog (Android DatePickerDialog and TimePickerDialog)

Though a Date Picker and Time Picker can be used as independent widgets but they occupy more space on the screen. Hence using them inside a Dialog is a better choice. Fortunately android provides use with its own DatePickerDialog and TimePickerDialog classes.

尽管可以将Date Picker和Time Picker用作独立的小部件,但它们在屏幕上占据了更多空间。 因此,在对话框中使用它们是更好的选择。 幸运的是,android提供了自己的DatePickerDialog和TimePickerDialog类。

DatePickerDialog and TimePickerDialog classes have onDateSetListener() and onTimeSetListener() callback methods respectively. These callback methods are invoked when the user is done with filling the date and time respectively.

DatePickerDialogTimePickerDialog类分别具有onDateSetListener()onTimeSetListener()回调方法。 当用户分别填写日期和时间后,将调用这些回调方法。

The DatePickerDialog class consists of a 5 argument constructor with the parameters listed below.

DatePickerDialog类由5个参数的构造函数以及下面列出的参数组成。

  1. Context: It requires the application context

    上下文 :它需要应用程序上下文
  2. CallBack Function: onDateSet() is invoked when the user sets the date with the following paramete
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值