Code example for TimePickerDialog

Methods: updateTime

0
        super.onPrepareDialog(id, dialog);
        switch (id) {
            case TIME_DIALOG_ID:
                String[] strings = timePreference.getSummary().toString().split(":");
                TimePickerDialog timePicker = (TimePickerDialog)dialog;
                timePicker.updateTime(Integer.parseInt(strings[0]), Integer.parseInt(strings[1]));
                break; 
        } 
    } 
 
    @Override 
    public void onTimeSet(TimePicker timePicker, int hourOfDay, int minute) {
        timePreference.setSummary(String.format("%02d:%02d", hourOfDay, minute));
        SaveScheduleItem(); 
    } 
 
    @Override 
    public boolean onCreateOptionsMenu(Menu menu) {
        super.onCreateOptionsMenu(menu);
 
        MenuItem deleteMenuItem = menu.add(R.string.delete_schedule_item);