Code example for TimePickerDialog

Methods: show

0
            hour = value / 60;
            minutes = value % 60;
        } 
 
        Context context = getContext();
        TimePickerDialog dlg = new TimePickerDialog(context,
        new TimePickerDialog.OnTimeSetListener() {
            @Override 
            public void onTimeSet(TimePicker v, int hours, int minutes) {
                int time = hours * 60 + minutes;
                if (key == DIALOG_START_TIME) {
                    mStartTime = time;
                    mStartTimeText.setText(returnTime(time));
                } else { 
                    mEndTime = time;
                    mEndTimeText.setText(returnTime(time));
                } 
                callChangeListener(this);
            }; 
        }, hour, minutes, DateFormat.is24HourFormat(context));
        dlg.show();
    } 
 
    private String returnTime(int t) {
        if (t < 0) {
            return ""; 
Stop searching for code, let great code find you!  Add Codota to your java IDE