]>
Commit | Line | Data |
---|---|---|
e6ba41a8 PT |
1 | package ro.ieval.unical; |
2 | ||
3 | import java.util.GregorianCalendar; | |
4 | ||
5 | import android.app.Dialog; | |
6 | import android.app.DialogFragment; | |
7 | import android.app.TimePickerDialog; | |
8 | import android.os.Bundle; | |
9 | import android.text.format.DateFormat; | |
10 | import android.widget.TimePicker; | |
11 | ||
12 | public class TimePickerFragment extends DialogFragment | |
13 | implements TimePickerDialog.OnTimeSetListener { | |
14 | ||
15 | @Override | |
16 | public Dialog onCreateDialog(Bundle savedInstanceState) { | |
17 | // Use the current time as the default values for the picker | |
18 | final GregorianCalendar c = (GregorianCalendar) GregorianCalendar.getInstance(); | |
19 | int hour = c.get(GregorianCalendar.HOUR_OF_DAY); | |
20 | int minute = c.get(GregorianCalendar.MINUTE); | |
21 | ||
22 | // Create a new instance of TimePickerDialog and return it | |
23 | return new TimePickerDialog(getActivity(), this, hour, minute, | |
24 | DateFormat.is24HourFormat(getActivity())); | |
25 | } | |
26 | ||
27 | @Override | |
28 | public void onTimeSet(TimePicker view, int hourOfDay, int minute) { | |
29 | // Do something with the time chosen by the user | |
30 | ||
31 | } | |
32 | } |