當前位置: 首頁>>代碼示例>>Java>>正文


Java TimePickerDialog.OnTimeSetListener方法代碼示例

本文整理匯總了Java中android.app.TimePickerDialog.OnTimeSetListener方法的典型用法代碼示例。如果您正苦於以下問題:Java TimePickerDialog.OnTimeSetListener方法的具體用法?Java TimePickerDialog.OnTimeSetListener怎麽用?Java TimePickerDialog.OnTimeSetListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.TimePickerDialog的用法示例。


在下文中一共展示了TimePickerDialog.OnTimeSetListener方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onBtnChooseTimeDialogClicked

import android.app.TimePickerDialog; //導入方法依賴的package包/類
@OnClick(R.id.btn_choose_time_dialog)
public void onBtnChooseTimeDialogClicked() {
    final Calendar calendar = Calendar.getInstance();
    TimePickerDialog dialog = new TimePickerDialog(
            this,
            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);
                    String time = DateFormat.getTimeInstance(DateFormat.SHORT).format(calendar.getTime());
                    ToastUtils.showShortToast(time);
                }
            },
            calendar.get(Calendar.HOUR_OF_DAY),
            calendar.get(Calendar.MINUTE),
            false
    );
    dialog.show();
}
 
開發者ID:jiangkang,項目名稱:KTools,代碼行數:21,代碼來源:KDialogActivity.java

示例2: showTime

import android.app.TimePickerDialog; //導入方法依賴的package包/類
private void showTime() {

    Calendar c = Calendar.getInstance();
    int mYear = c.get(Calendar.YEAR);
    int mMonth = c.get(Calendar.MONTH);
    int mDay = c.get(Calendar.DAY_OF_MONTH);
    int mHour = c.get(Calendar.HOUR_OF_DAY);
    int mMinute = c.get(Calendar.MINUTE);
    TimePickerDialog dialog =
        new TimePickerDialog(getActivity(), new TimePickerDialog.OnTimeSetListener() {
          @Override public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

          }
        }, mHour, mMinute, true);
    dialog.show();
  }
 
開發者ID:liuguoquan727,項目名稱:android-study,代碼行數:17,代碼來源:DateUI.java

示例3: getOnTimeSetListener

import android.app.TimePickerDialog; //導入方法依賴的package包/類
private static TimePickerDialog.OnTimeSetListener getOnTimeSetListener(final EditText txtDate) {
    TimePickerDialog.OnTimeSetListener listener = new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            String hour = hourOfDay + "";
            if (hourOfDay < 10) {
                hour = "0" + hourOfDay;
            }
            String min = minute + "";
            if (minute < 10)
                min = "0" + minute;
            txtDate.setText(hour + ":" + min);
        }
    };
    return listener;
}
 
開發者ID:lidox,項目名稱:reaction-test,代碼行數:17,代碼來源:DialogHelper.java

示例4: taskDueTimeOnClickBehavior

import android.app.TimePickerDialog; //導入方法依賴的package包/類
@OnClick(R.id.task_due_time_content)
void taskDueTimeOnClickBehavior() {
    TimePickerDialog.OnTimeSetListener time = new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker timePicker, int hourOfDay, int minuteOfHour) {
            dueCalendar.set(Calendar.HOUR_OF_DAY, hourOfDay);
            dueCalendar.set(Calendar.MINUTE, minuteOfHour);
            DateFormat sdf = android.text.format.DateFormat.getTimeFormat(getBaseContext());
            dueTimeContent.setText(sdf.format(dueCalendar.getTime()));
            setTime = true;
        }
    };
    new TimePickerDialog(this, time,
            dueCalendar.get(Calendar.HOUR_OF_DAY),
            dueCalendar.get(Calendar.MINUTE), true).show();
}
 
開發者ID:AndroidNewbies,項目名稱:Sanxing,代碼行數:17,代碼來源:OperateTaskActivityBase.java

示例5: reminderTimePickerDialog

import android.app.TimePickerDialog; //導入方法依賴的package包/類
public void reminderTimePickerDialog() {
    final Calendar calendar = Calendar.getInstance();
    int mHour = calendar.get(Calendar.HOUR_OF_DAY);
    int mMinute = calendar.get(Calendar.MINUTE);

    final SimpleDateFormat simpleTimeFormat = new SimpleDateFormat("hh:mm a", Locale.US);

    final ToodooTimePickerDialog timePickerDialog = new ToodooTimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker timePicker, int hour, int minute) {
            reminderCalendar.set(Calendar.HOUR_OF_DAY, hour);
            reminderCalendar.set(Calendar.MINUTE, minute);
            selectedReminderValue = reminderCalendar.getTime();
            reminderTimeValue = simpleTimeFormat.format(selectedReminderValue);

            selectedReminder = reminderDateValue + " @ " + reminderTimeValue;

            ToodooOptionsModel ToodooOptionsModel = toodooOptionsList.get(2);
            ToodooOptionsModel.setOptionValue(selectedReminder);
            mAdapter.notifyDataSetChanged();
        }
    }, mHour, mMinute, true);
    timePickerDialog.show();
}
 
開發者ID:OlayinkaPeter,項目名稱:Toodoo,代碼行數:25,代碼來源:ToodooNote.java

示例6: showTimePickerDialog

import android.app.TimePickerDialog; //導入方法依賴的package包/類
/**
 * Shows time picker dialog and handles the time selected by user
 * @param viewWhoIsCallingIt View whose time time needs to be updated after user selects time
 * @param prefKey Preference for the key needed to be updated after user selects time
 */
private void showTimePickerDialog(final KeyValueView viewWhoIsCallingIt, final String prefKey) {
    int time[] = TimeUtils.getCurrentTimeAsHourAndMinutes();
    TimePickerDialog timePickerDialog = new TimePickerDialog(context, new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker timePicker, int i, int i1) {
            String selectedHour = i < 10 ? "0" + i: "" + i;
            String selectedMinute = i1 < 10 ? "0" +i1: "" + i1;
            String timeString = selectedHour + ":" + selectedMinute;

            PreferenceHelper.putString(context, prefKey, timeString);
            // We also backup the time here
            // To get the prefKey for backup, its "last_" + prefKey
            PreferenceHelper.putString(context, "last_" + prefKey, timeString);

            viewWhoIsCallingIt.setValue(timeString);

            addNextDayIfNecessary();

            doCurrentAutoFunctions(true);
        }
    }, time[0], time[1], false);
    timePickerDialog.show();
}
 
開發者ID:corphish,項目名稱:NightLight,代碼行數:29,代碼來源:AutoFragment.java

示例7: openTimePicker

import android.app.TimePickerDialog; //導入方法依賴的package包/類
private void openTimePicker(){
    final Calendar c = Calendar.getInstance();
    int mHour = c.get(Calendar.HOUR_OF_DAY);
    int mMinute = c.get(Calendar.MINUTE);
    TimePickerDialog timePickerDialog = new TimePickerDialog(this,
            new TimePickerDialog.OnTimeSetListener() {

                @Override
                public void onTimeSet(TimePicker view, int hourOfDay,
                                      int minute) {
                    String date = btnPollExpiryTime.getText().toString();
                    btnPollExpiryTime.setText(date+" "+ hourOfDay + ":" + minute);
                }
            }, mHour, mMinute, false);
    timePickerDialog.show();
}
 
開發者ID:StringflowServer,項目名稱:Beach-Android,代碼行數:17,代碼來源:PollActivity.java

示例8: pickTime

import android.app.TimePickerDialog; //導入方法依賴的package包/類
/**
 * Pick the time that the homework item is due in for.
 */
public void pickTime() {
    TimePickerDialog dialog = new TimePickerDialog(AddExam.this, new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            hours = hourOfDay;
            minutes = minute;

            exam.setPeriod(-1);
            exam.setTime(Methods.convert(hourOfDay) + ":" + Methods.convert(minute));
            timeChecker = true;

            showUpdate();
            showSubmit();
            updateSwitcher(dateChecker, timeChecker);
        }
    }, hours, minutes, true);
    dialog.show();
}
 
開發者ID:pkgprateek,項目名稱:Mad-Planner,代碼行數:22,代碼來源:AddExam.java

示例9: pickTime

import android.app.TimePickerDialog; //導入方法依賴的package包/類
/**
 * Pick the time that the homework item is due in for.
 */
public void pickTime() {
    TimePickerDialog dialog = new TimePickerDialog(AddHomework.this, new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            hours = hourOfDay;
            minutes = minute;

            homeworkItem.setPeriod(-1);
            homeworkItem.setTime(Methods.convert(hourOfDay) + ":" + Methods.convert(minute));
            timeChecker = true;

            showUpdate();
            showSubmit();
            updateSwitcher(dateChecker, timeChecker);
        }
    }, hours, minutes, true);
    dialog.show();
}
 
開發者ID:pkgprateek,項目名稱:Mad-Planner,代碼行數:22,代碼來源:AddHomework.java

示例10: newInstance

import android.app.TimePickerDialog; //導入方法依賴的package包/類
public static TimePickerFragment newInstance(
        TimePickerDialog.OnTimeSetListener onTimeSetListener
) {
    TimePickerFragment fragment = new TimePickerFragment();
    fragment.onTimeSetListener = onTimeSetListener;

    return fragment;
}
 
開發者ID:raatiniemi,項目名稱:worker,代碼行數:9,代碼來源:TimePickerFragment.java

示例11: onCreate

import android.app.TimePickerDialog; //導入方法依賴的package包/類
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);

    dbHandler = AlarmDBOpenHelper.getAlarmDBOpenHelper(getActivity());

    timePickerDialog = new TimePickerDialog(getActivity(), R.style.AppTheme_Timepicker,
            new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            try {
                alarm.setHour(hourOfDay);
                alarm.setMinute(minute);
            } catch(Exception e) {
                e.printStackTrace();
            }
            setAlarmTimeView.setText(alarm.getTimeString(use24Hours));
            setAlarmAMPMView.setText(alarm.getAMPMSuffix(use24Hours));
            timeValueSet = true;
        }
    }, 0, 0, true);

    use24Hours = PreferenceManager.getDefaultSharedPreferences(getActivity())
            .getBoolean(this.getString(R.string.use24Hours), false);
}
 
開發者ID:theScrabi,項目名稱:Terminightor,代碼行數:27,代碼來源:AlarmItemDetailFragment.java

示例12: showTimePickerStop

import android.app.TimePickerDialog; //導入方法依賴的package包/類
public void showTimePickerStop(View view) {
    final Calendar cal = calEnd;
    TimePickerDialog dialog = new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker picker, int hourOfDay, int minute) {
            cal.set(Calendar.HOUR_OF_DAY, hourOfDay);
            cal.set(Calendar.MINUTE, minute);

            //check consistency: recording's end after start?
            if (!calEnd.after(calStart)) {
                // reset start to a time just before end
                calStart.setTime(calEnd.getTime());
                calStart.add(Calendar.MINUTE, -1); //time was changed, so difference will be 1 minute

                //TODO: somehow highlight the changed start time?
            }

            updateTimeViews();
        }
    }, cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE), true);
    dialog.show();
}
 
開發者ID:MC-Timetracker,項目名稱:timetracker,代碼行數:23,代碼來源:EditRecordingActivity.java

示例13: selectTime

import android.app.TimePickerDialog; //導入方法依賴的package包/類
private void selectTime(final View view) {
    // Launch the timepreference
    // Set the view with the time.

    Toast.makeText(this, "Clicked time", Toast.LENGTH_SHORT).show();

    TimePickerDialog.OnTimeSetListener timeSetListener = new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker timePicker, int hour, int minute) {
            Calendar tempTime = convertToCalendar(hour, minute);
            setTextAndTagOnTimeView(view, tempTime);
        }
    };

    Calendar time = (Calendar)view.getTag();
    TimePickerDialog tpDialog =
            new TimePickerDialog(this,
                                 timeSetListener,
                                 time.get(Calendar.HOUR_OF_DAY),
                                 time.get(Calendar.MINUTE),
                                 false);
    tpDialog.show();
}
 
開發者ID:alberto234,項目名稱:schedule-alarm-manager,代碼行數:24,代碼來源:ScheduleTestActivity.java

示例14: setCountDownTime

import android.app.TimePickerDialog; //導入方法依賴的package包/類
private void setCountDownTime(final CountDownTimerView countDownTimerView)
{
	TimePickerDialog timePickerDialog = new TimePickerDialog(this, new TimePickerDialog.OnTimeSetListener()
	{
		//hours are taken as minutes and minutes as seconds
		@Override
		public void onTimeSet(TimePicker view, int minute, int second)
		{
			long countDownMillis = (minute * 60 + second) * 1000;
			countDownTimerView.setCountDownTime(countDownMillis);
		}
	}, 0, 0, true);
	timePickerDialog.setTitle(getString(R.string.minutes_and_seconds));

	timePickerDialog.show();
}
 
開發者ID:jraska,項目名稱:TimerViews,代碼行數:17,代碼來源:CountDownTimersActivity.java

示例15: onCreateDialog

import android.app.TimePickerDialog; //導入方法依賴的package包/類
@Override 
public Dialog onCreateDialog(int id) {
	switch (id) {
	case DIALOG_TIME:
		return new TimePickerDialog(this,
				new TimePickerDialog.OnTimeSetListener() {
					public void onTimeSet(TimePicker view, int hourOfDay,
							int minute) {
						mTime.set(Calendar.HOUR_OF_DAY, hourOfDay);
						mTime.set(Calendar.MINUTE, minute);
						mClock.setTime(hourOfDay, minute, 0);
					}
				}, mTime.get(Calendar.HOUR_OF_DAY),
				mTime.get(Calendar.MINUTE), false);
	default:
		return null;
	}
}
 
開發者ID:cnevinc,項目名稱:Movement,代碼行數:19,代碼來源:Act_CreateRecord.java


注:本文中的android.app.TimePickerDialog.OnTimeSetListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。