2

Is need to allow only to change hours, how can it be done?

In simple TimePicker, i can set the TimePicker.OnTimeChangedListener interface, but this interface is not available in TimePickerDialog.

Name is Nilay
  • 2,743
  • 4
  • 35
  • 77
SpeedBirdNine
  • 4,610
  • 11
  • 49
  • 67

3 Answers3

1

Use getCurrentHour() and setCurrentHour(), and set the minutes to 0.

Sergio
  • 640
  • 6
  • 23
1

You can copy the source of the original Widget and its layout and include it in your own project as a "library" class. You will also need to update the source's references to R. With the layout you can show anything you'd like in regards to not having minutes being editable. Since this is homework be sure to correctly note that you're customizing widget from Android source library.

Dan S
  • 9,139
  • 3
  • 37
  • 48
0

The documentation doesn't show any way to do that, so I guess there is no such a way. You could subclass the TimePicker class and disable the minute picker yourself, somehow, but there is no reason to work so much.

However, you can set the value to 0 (TimePicker.setCurrentMinute(0)) and if the user changes it, just ignore. And you should inform the user that changing the minute doesn't matter, as you don't use it.

Jong
  • 9,045
  • 3
  • 34
  • 66