Code example for TimePicker

Methods: getContextsetCurrentHoursetCurrentMinutesetIs24HourView

0
    } 
  
    @Override 
    protected View onCreateDialogView() {
 
        tp = new TimePicker(getContext());
 
        String time = getPersistedString(defaultValue);
        if (time == null || !time.matches(VALIDATION_EXPRESSION)) {
            return tp;
        } 
 
        String[] timeParts = time.split(":");
 
        int h = Integer.parseInt(timeParts[0]);
        int m = Integer.parseInt(timeParts[1]);
        if (h >= 0 && m >= 0) {
            tp.setCurrentHour(h);
            tp.setCurrentMinute(m);
        } 
 
        tp.setIs24HourView(DateFormat.is24HourFormat(tp.getContext()));
 
        return tp;
    } 
 
    @Override 
Stop searching for code, let great code find you!  Add Codota to your java IDE