0

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?

Community
  • 1
  • 1
YoungDinosaur
  • 1,550
  • 17
  • 22
  • 1
    Instead of using `TimePicker` you could use two `NumberPicker`s which would allow you to set min and max on the hour. Although, I would think if you were able to set the minute options then you should be able to also set the hour options. I've only used `NumberPicker` in the past. – DigitalNinja Mar 23 '15 at 23:12
  • Rather than set min and max (which wouldn't work too well with time (non-24hr format), with a `NumberPicker` you can set the values that get displayed. – DigitalNinja Mar 23 '15 at 23:20

1 Answers1

0

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.

JoKr
  • 4,976
  • 8
  • 27
  • 39