‫Welcome back.
‫In this video, we'll learn about time pickers.
‫A time picker is a UI widget that allows users to select a specific time of day using a graphical interface.
‫It's commonly used in scenarios where you need to gather time related information from the user, such
‫as setting alarms or scheduling events.
‫Let's create a time picker example in Android studio.
‫Start with the time picker tag wrap content wrap content and you can see it appears I'll add the ID
‫of this time picker and that's it.
‫Infer constraints and we've done with the XML.
‫Let's move to the main activity dot Java and here I'll, I'll initialize the time picker.
‫We need to listen for the changes in the time picker So when the user selects a specific time, we need
‫to listen to this change.
‫So we need to set up on time change.
‫Listener So time picker here dot set on time change Listener New time picker and on time changed.
‫I need to handle time change the hour of day and minute are parameters provide the selected time so
‫when the user select the time it will be stored in this hour of day and minute parameters.
‫And I can make of use of these two parameters in order to display the user picked time.
‫So I need to create a toast message that allows us to display the time that the user selected.
‫I'll make it as length long hour and I'll use hour of day plus and I'll make a concatenation of this
‫string minute.
‫Let's run our application and this is our example.
‫If I select eight and our 50, you can see our 20 and minute 50.
‫If you want to re select the time I click the hour eight, I can select, for example, a m, hour eight
‫and not 24 and minutes zero zero.
‫You can see hour four and minute zero.