Reputation: 1560
I'm using a TimePicker to allow a user to select a scheduled time slot during a business day. For example the user could use the TimePicker to schedule a meeting at 8:00am, 8:30am, 9:30am , etc... all the way to 8:00pm. Based on the response from https://stackoverflow.com/a/20396673/950953 I've managed to limit the minute picker to two options of 0 and 30. However, I cannot figure out how to limit the hour picker to start at 8am and end at 8pm. Any ideas?
Upvotes: 0
Views: 2123
Reputation: 5266
I don't know proper way, but if you don't find anything you can try something like:
Set picker to e.g. 8:00, and you can get moment when user start scrolling with setOnTimeChangedListener (TimePicker.OnTimeChangedListener onTimeChangedListener)
In that listener check if user was scrolling up or down, and manually set the picker let's say 8:30. It will still be shitty, because within picker user will se minutes ascending by 1, but he will scroll for 30 minutes.
Upvotes: 0