Android: Focus on TimePicker elements

You can get each NumberPicker of TimePicker and make whatever you want such as modify, request the focus and so on.

NumberPicker hourPicker = (NumberPicker) mTimePicker.findViewById(Resources.getSystem().getIdentifier("hour",
     "id", "android"));

NumberPicker minutePicker = (NumberPicker) mTimePicker.findViewById(Resources.getSystem().getIdentifier("minute",
     "id", "android"));

NumberPicker amPmPicker = (NumberPicker) mTimePicker.findViewById(Resources.getSystem().getIdentifier("amPm",
     "id", "android"));

// this is a number picker modified and there is one for each NumerPicker above
View numberPickerModified = (View) mTimePicker.findViewById(Resources.getSystem().getIdentifier("numberpicker_input",
     "id", "android"));

Leave a Comment