Learn to use Android time and date picker (datepicker, TimePicker)

In order to enable users to select time and date, Android provides datepicker date picker and TimePicker time picker. The use of these two components is very simple. You can directly drag and drop them into the layout on the visual interface of eclipse. After the user makes a selection on the event date selector, the user's selection needs to be read out, which requires adding a corresponding listener to the component.

1、 Date picker

1. Drag and drop components into the layout on the eclipse visual interface

2. Get date component in layout

3. Create a calendar object to get the current calendar time

4. Initialize the date selector and bind the listener

The operation effect is as follows: in terms of event monitoring: a prompt box will be displayed after clicking the date

2、 Time picker

1. Drag and drop components into the layout on the eclipse visual interface

2. Get date component in layout

3. Create a calendar object to get the current calendar time

4. Bind listener

The operation effect is as follows. After clicking the time selection, a prompt box will be displayed

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>