Пример #1
0
 public TimePickerDialog(
     Context context,
     int theme,
     OnTimeSetListener callBack,
     int hourOfDay,
     int minute,
     boolean is24HourView) {
   super(context, theme);
   mCallback = callBack;
   mInitialHourOfDay = hourOfDay;
   mInitialMinute = minute;
   mIs24HourView = is24HourView;
   setIcon(0);
   setTitle(R.string.time_picker_dialog_title);
   Context themeContext = getContext();
   setButton(DialogInterface.BUTTON_POSITIVE, themeContext.getText(R.string.date_time_set), this);
   setButton(
       DialogInterface.BUTTON_NEGATIVE,
       themeContext.getText(android.R.string.cancel),
       (OnClickListener) null);
   View view = LayoutInflater.inflate(themeContext, R.layout.time_picker_dialog);
   setView(view);
   mTimePicker = (TimePicker) view.findViewById(R.id.timePicker);
   mTimePicker.setIs24HourView(mIs24HourView);
   mTimePicker.setCurrentHour(mInitialHourOfDay);
   mTimePicker.setCurrentMinute(mInitialMinute);
   mTimePicker.setOnTimeChangedListener(this);
 }
Пример #2
0
 @Override
 public Bundle onSaveInstanceState() {
   Bundle state = super.onSaveInstanceState();
   state.putInt(TimePickerDialog.HOUR, mTimePicker.getCurrentHour());
   state.putInt(TimePickerDialog.MINUTE, mTimePicker.getCurrentMinute());
   state.putBoolean(TimePickerDialog.IS_24_HOUR, mTimePicker.is24HourView());
   return state;
 }
Пример #3
0
 @Override
 public void onClick(DialogInterface dialog, int which) {
   if (mCallback != null) {
     mTimePicker.clearFocus();
     mCallback.onTimeSet(
         mTimePicker, mTimePicker.getCurrentHour(), mTimePicker.getCurrentMinute());
   }
 }
Пример #4
0
 @Override
 public void onRestoreInstanceState(Bundle savedInstanceState) {
   super.onRestoreInstanceState(savedInstanceState);
   int hour = savedInstanceState.getInt(TimePickerDialog.HOUR);
   int minute = savedInstanceState.getInt(TimePickerDialog.MINUTE);
   mTimePicker.setIs24HourView(savedInstanceState.getBoolean(TimePickerDialog.IS_24_HOUR));
   mTimePicker.setCurrentHour(hour);
   mTimePicker.setCurrentMinute(minute);
 }
Пример #5
0
 public void updateTime(int hourOfDay, int minutOfHour) {
   mTimePicker.setCurrentHour(hourOfDay);
   mTimePicker.setCurrentMinute(minutOfHour);
 }