Code example for TimePickerDialog

0
        final Calendar c = Calendar.getInstance();
        int hour = c.get(Calendar.HOUR_OF_DAY);
        int minute = c.get(Calendar.MINUTE);
 
        // TimePickerDialogを生成して返す 
        return new TimePickerDialog(getActivity(), this, hour, minute, is24HourView);
    } 
 
    public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
        // 時刻が選択された時に呼び出される 
        String text = String.format("%d:%d", hourOfDay, minute);
        Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT).show();
    } 
}