Java Code Examples for android.app.TimePickerDialog#OnTimeSetListener
The following examples show how to use
android.app.TimePickerDialog#OnTimeSetListener .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OCM_ChildMenu.java From GLEXP-Team-onebillion with Apache License 2.0 | 6 votes |
void showPickTimeDialog (final TimePickerDialog.OnTimeSetListener listener) { final DatePickerDialog.OnDateSetListener dateListener = (DatePickerDialog.OnDateSetListener) listener; final Calendar calendar = Calendar.getInstance(); TimePickerDialog d = new TimePickerDialog(MainActivity.mainActivity, listener, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), DateFormat.is24HourFormat(MainActivity.mainActivity)); // d.setCancelable(false); d.setCanceledOnTouchOutside(false); // d.setButton(DatePickerDialog.BUTTON_NEGATIVE, "Back", new DialogInterface.OnClickListener() { @Override public void onClick (DialogInterface dialog, int which) { showPickDateDialog(dateListener, null); } }); // LinearLayout linearLayout = new LinearLayout(MainActivity.mainActivity.getApplicationContext()); d.requestWindowFeature(Window.FEATURE_NO_TITLE); d.setCustomTitle(linearLayout); // d.show(); }
Example 2
Source File: PreferencesFragment.java From HouSi with Apache License 2.0 | 6 votes |
private void showTimePicker() { final Calendar calendar = Calendar.getInstance(); String startTime = QueryPreferences.getSettingServiceStartTime(getContext()); if (startTime != null) { calendar.setTimeInMillis(Long.parseLong(startTime)); } TimePickerDialog timePickerDialog = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker timePicker, int hourOfDay, int minute) { calendar.set(Calendar.HOUR_OF_DAY, hourOfDay); calendar.set(Calendar.MINUTE, minute); QueryPreferences.setSettingServiceStartTime(getContext(), calendar.getTimeInMillis() + ""); mSettingServiceStartTime.setSummary(SERVICE_START_TIME_FORMAT.format(calendar.getTime())); } }, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), true); timePickerDialog.setTitle("设置时间"); timePickerDialog.show(); }
Example 3
Source File: FragmentDarkThemeViewModel.java From iGap-Android with GNU Affero General Public License v3.0 | 6 votes |
public void onClickFromTime(View v) { sharedPreferences = G.context.getSharedPreferences(SHP_SETTING.FILE_NAME, MODE_PRIVATE); int hour = sharedPreferences.getInt(SHP_SETTING.KEY_SELECTED_HOUR_FROM, 8); int minute = sharedPreferences.getInt(SHP_SETTING.KEY_SELECTED_MINUTE_FROM, 0); TimePickerDialog mTimePicker = new TimePickerDialog(G.currentActivity, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) { long fNow = (selectedHour * 3600000) + (selectedMinute * 60000); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putInt(SHP_SETTING.KEY_SELECTED_HOUR_FROM, selectedHour); editor.putInt(SHP_SETTING.KEY_SELECTED_MINUTE_FROM, selectedMinute); editor.putLong(SHP_SETTING.KEY_SELECTED_MILISECOND_FROM, fNow); editor.apply(); callbackFromTime.set("" + selectedHour + ":" + selectedMinute); } }, hour, minute, true);//Yes 24 hour time mTimePicker.setTitle(G.context.getResources().getString(R.string.Select_Time)); mTimePicker.show(); }
Example 4
Source File: FragmentDarkThemeViewModel.java From iGap-Android with GNU Affero General Public License v3.0 | 6 votes |
public void onClickToTime(View v) { sharedPreferences = G.context.getSharedPreferences(SHP_SETTING.FILE_NAME, MODE_PRIVATE); int hour = sharedPreferences.getInt(SHP_SETTING.KEY_SELECTED_HOUR_TO, 8); int minute = sharedPreferences.getInt(SHP_SETTING.KEY_SELECTED_MINUTE_TO, 0); TimePickerDialog mTimePicker = new TimePickerDialog(G.currentActivity, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) { long fNow = (selectedHour * 3600000) + (selectedMinute * 60000); SharedPreferences.Editor editor = sharedPreferences.edit(); editor.putInt(SHP_SETTING.KEY_SELECTED_HOUR_TO, selectedHour); editor.putInt(SHP_SETTING.KEY_SELECTED_MINUTE_TO, selectedMinute); editor.putLong(SHP_SETTING.KEY_SELECTED_MILISECOND_TO, fNow); editor.apply(); callbackToTime.set("" + selectedHour + ":" + selectedMinute); } }, hour, minute, true);//Yes 24 hour time mTimePicker.setTitle(G.context.getResources().getString(R.string.Select_Time)); mTimePicker.show(); }
Example 5
Source File: AEditText.java From Stylish-Widget-for-Android with Apache License 2.0 | 6 votes |
public void createTimePicker(final boolean isDateTimePicker) { timePicker = new TimePickerDialog( getContext(), new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { calendar.set(Calendar.HOUR_OF_DAY, hourOfDay); calendar.set(Calendar.MINUTE, minute); if (isDateTimePicker) displayDateTime(); else displayTime(); } }, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), is24Hours ); }
Example 6
Source File: SelfRouteDetailActivity.java From kute with Apache License 2.0 | 6 votes |
/********************** Custom Functions *********************/ //Creates the dialog for time picking public void setupTimePickerDialog(){ // Get Current Time Calendar c = Calendar.getInstance(); int mHour = c.get(Calendar.HOUR_OF_DAY); int mMinute = c.get(Calendar.MINUTE); // Launch Time Picker Dialog TimePickerDialog timePickerDialog = new TimePickerDialog(this,R.style.TimePickerTheme, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { Toast.makeText(SelfRouteDetailActivity.this,Integer.toString(hourOfDay),Toast.LENGTH_SHORT).show(); String time_string=Integer.toString(hourOfDay)+":"+Integer.toString(minute); time.setText(time_string); } }, mHour, mMinute, false); timePickerDialog.show(); }
Example 7
Source File: AddTrip.java From kute with Apache License 2.0 | 6 votes |
private void setupTimePicker(){ // Get Current Time Calendar c = Calendar.getInstance(); int mHour = c.get(Calendar.HOUR_OF_DAY); int mMinute = c.get(Calendar.MINUTE); // Launch Time Picker Dialog TimePickerDialog timePickerDialog = new TimePickerDialog(this,R.style.TimePickerTheme, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { Toast.makeText(AddTrip.this,Integer.toString(hourOfDay),Toast.LENGTH_SHORT).show(); String time_string1=Integer.toString(hourOfDay)+":"+Integer.toString(minute); time.setText(time_string1); time_string=time_string1; } }, mHour, mMinute, false); timePickerDialog.show(); }
Example 8
Source File: DismissableTimePickerDialog.java From react-native-GPay with MIT License | 5 votes |
public DismissableTimePickerDialog( Context context, int theme, @Nullable TimePickerDialog.OnTimeSetListener callback, int hourOfDay, int minute, boolean is24HourView) { super(context, theme, callback, hourOfDay, minute, is24HourView); }
Example 9
Source File: TabbedActivity.java From holoaccent with Apache License 2.0 | 5 votes |
private void showTimePickerDialog() { final Calendar c = Calendar.getInstance(); int hour = c.get(Calendar.HOUR_OF_DAY); int minute = c.get(Calendar.MINUTE); // Create a new instance of TimePickerDialog and return it TimePickerDialog.OnTimeSetListener listener = new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(android.widget.TimePicker timePicker, int i, int i1) { } }; new AccentTimePickerDialog(this, listener, hour, minute, DateFormat.is24HourFormat(this)).show(); }
Example 10
Source File: Picker_Fragment.java From ui with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View myView = inflater.inflate(R.layout.picker_fragment, container, false); tv_date = myView.findViewById(R.id.tv_date); tv_time = myView.findViewById(R.id.tv_time); btn_date = myView.findViewById(R.id.btn_date); btn_date.setOnClickListener(this); btn_time = myView.findViewById(R.id.btn_time); btn_time.setOnClickListener(this); //create the date picker listener, which is used later when the picker is called. d = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { dateAndTime.set(Calendar.YEAR, year); dateAndTime.set(Calendar.MONTH, monthOfYear); dateAndTime.set(Calendar.DAY_OF_MONTH, dayOfMonth); tv_date.setText(fmtDate.format(dateAndTime.getTime())); } }; //create the time picker listener t = new TimePickerDialog.OnTimeSetListener() { public void onTimeSet(TimePicker view, int selectedHour, int selectedMinute) { dateAndTime.set(Calendar.HOUR, selectedHour); dateAndTime.set(Calendar.MINUTE, selectedMinute); // set current time into textview tv_time.setText(fmtTime.format(dateAndTime.getTime())); } }; return myView; }
Example 11
Source File: Picker_Fragment.java From ui with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View myView = inflater.inflate(R.layout.picker_fragment, container, false); tv_date = myView.findViewById(R.id.tv_date); tv_time = myView.findViewById(R.id.tv_time); btn_date = myView.findViewById(R.id.btn_date); btn_date.setOnClickListener(this); btn_time = myView.findViewById(R.id.btn_time); btn_time.setOnClickListener(this); //create the date picker listener, which is used later when the picker is called. d = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { dateAndTime.set(Calendar.YEAR, year); dateAndTime.set(Calendar.MONTH, monthOfYear); dateAndTime.set(Calendar.DAY_OF_MONTH, dayOfMonth); tv_date.setText(fmtDate.format(dateAndTime.getTime())); } }; //create the time picker listener t = new TimePickerDialog.OnTimeSetListener() { public void onTimeSet(TimePicker view, int selectedHour, int selectedMinute) { dateAndTime.set(Calendar.HOUR, selectedHour); dateAndTime.set(Calendar.MINUTE, selectedMinute); // set current time into textview tv_time.setText(fmtTime.format(dateAndTime.getTime())); } }; return myView; }
Example 12
Source File: ReminderEditActivity.java From Task-Reminder-App with MIT License | 5 votes |
private TimePickerDialog showTimePicker() { TimePickerDialog timePicker = new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { mCalendar.set(Calendar.HOUR_OF_DAY, hourOfDay); mCalendar.set(Calendar.MINUTE, minute); updateTimeButtonText(); } }, mCalendar.get(Calendar.HOUR_OF_DAY), mCalendar.get(Calendar.MINUTE), true); return timePicker; }
Example 13
Source File: InactiveTimePreference.java From AcDisplay with GNU General Public License v2.0 | 5 votes |
@Override public void onClick(View v) { final Data data = v == mFrom.labelTextView ? mFrom : mTo; TimePickerDialog timePickerDialog = new TimePickerDialog(getContext(), new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker timePicker, int selectedHour, int selectedMinute) { data.setTime(getContext(), selectedHour, selectedMinute); } }, data.hours, data.minutes, true ); timePickerDialog.show(); }
Example 14
Source File: TimePickerDialogFragment.java From white-label-event-app with Apache License 2.0 | 5 votes |
@Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) { Activity activity = getActivity(); if (activity instanceof TimePickerDialog.OnTimeSetListener) { ((TimePickerDialog.OnTimeSetListener) activity).onTimeSet(view, hourOfDay, minute); } }
Example 15
Source File: OBSetupMenu.java From GLEXP-Team-onebillion with Apache License 2.0 | 5 votes |
void showPickTimeDialog (final TimePickerDialog.OnTimeSetListener listener) { final DatePickerDialog.OnDateSetListener dateListener = (DatePickerDialog.OnDateSetListener) listener; final Calendar calendar = Calendar.getInstance(); TimePickerDialog d = new TimePickerDialog(MainActivity.mainActivity, listener, calendar.get(Calendar.HOUR_OF_DAY), calendar.get(Calendar.MINUTE), DateFormat.is24HourFormat(MainActivity.mainActivity)); // d.setCancelable(false); d.setCanceledOnTouchOutside(false); // d.setButton(DatePickerDialog.BUTTON_NEGATIVE, "Back", new DialogInterface.OnClickListener() { @Override public void onClick (DialogInterface dialog, int which) { if (screenType == ScreenType.SET_DATE_SCREEN) { showPickDateDialog(dateListener, null); } else { MainActivity.log("OBSetupMenu:showPickTimeDialog:cancelled!"); } } }); // LinearLayout linearLayout = new LinearLayout(MainActivity.mainActivity.getApplicationContext()); d.requestWindowFeature(Window.FEATURE_NO_TITLE); d.setCustomTitle(linearLayout); // d.show(); }
Example 16
Source File: DismissableTimePickerDialog.java From react-native-GPay with MIT License | 5 votes |
public DismissableTimePickerDialog( Context context, @Nullable TimePickerDialog.OnTimeSetListener callback, int hourOfDay, int minute, boolean is24HourView) { super(context, callback, hourOfDay, minute, is24HourView); }
Example 17
Source File: DialogManager.java From Expense-Tracker-App with MIT License | 4 votes |
public void createTimePickerDialog(Activity activity, int hour, int minute, TimePickerDialog.OnTimeSetListener listener) { new TimePickerDialog(activity, listener, hour, minute, DateFormat.is24HourFormat(activity)).show(); }
Example 18
Source File: TimePickerFragment.java From RoomBookerMVP with MIT License | 4 votes |
public void setOnTimeSetListener(TimePickerDialog.OnTimeSetListener onTimeSetListener) { this.onTimeSetListener = onTimeSetListener; }
Example 19
Source File: TimePickerProxy.java From TiDialogs with MIT License | 4 votes |
private TimePickerDialog getDialog() { TimePickerDialog picker = new TimePickerDialog(this.proxy.getActivity(), new TimePickerDialog.OnTimeSetListener() { @Override public void onTimeSet(TimePicker selectedTime, int selectedHour, int selectedMinute) { // TODO Auto-generated method stub hour = selectedHour; minute = selectedMinute; KrollDict data = new KrollDict(); Calendar calendar = Calendar.getInstance(); calendar.set(Calendar.HOUR_OF_DAY, hour); calendar.set(Calendar.MINUTE, minute); Date value = calendar.getTime(); data.put("value", value); data.put("hour", hour); data.put("minute", minute); fireEvent("click", data); } }, hour, minute, DateFormat.is24HourFormat(this.proxy .getActivity())); picker.setCanceledOnTouchOutside(false); picker.setButton(DialogInterface.BUTTON_POSITIVE, okButtonTitle, picker); picker.setButton(DialogInterface.BUTTON_NEGATIVE, cancelButtonTitle, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { fireEvent("cancel", new KrollDict()); } }); return picker; }
Example 20
Source File: HistoryDetailActivity.java From ActivityDiary with GNU General Public License v3.0 | 4 votes |
public void setData(TimePickerDialog.OnTimeSetListener listener, int hour, int minute){ this.hour = hour; this.minute = minute; this.listener = listener; }