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


Java TimePickerDialog.show方法代碼示例

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


在下文中一共展示了TimePickerDialog.show方法的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: onDateSet

import android.app.TimePickerDialog; //導入方法依賴的package包/類
public void onDateSet() {
    final TimePickerDialog timePicker = new TimePickerDialog(getActivity(), this, hour, minute, true);

    timePicker.setCanceledOnTouchOutside(true);
    timePicker.setCancelable(true);

    timePicker.setButton(DialogInterface.BUTTON_NEGATIVE, "Ahora", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int which) {
            final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("CET"));
            timePicker.updateTime(c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE));
            onTimeSet(null, c.get(Calendar.HOUR_OF_DAY), c.get(Calendar.MINUTE));
        }
    });
    timePicker.show();
}
 
開發者ID:medialab-prado,項目名稱:puremadrid,代碼行數:17,代碼來源:DatePickerFragment.java

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: onClick

import android.app.TimePickerDialog; //導入方法依賴的package包/類
@Override
public void onClick(View v)
{
    if(edittext == null) {
        return;
    }

    String[] time;

    if(edittext.getText().toString().equals("")) {
        Calendar c = Calendar.getInstance();
        time = new String[2];
        time[0] = (c.get(Calendar.HOUR_OF_DAY) < 10) ? "0" + c.get(Calendar.HOUR_OF_DAY) : "" + c.get(Calendar.HOUR_OF_DAY);
        time[1] = (c.get(Calendar.MINUTE) < 10) ? "0" + c.get(Calendar.MINUTE) : "" + c.get(Calendar.MINUTE);
    } else {
        time = edittext.getText().toString().split(":");
    }

    TimePickerDialog dialog = new TimePickerDialog(context, timePickerListener, Integer.parseInt(time[0]), Integer.parseInt(time[1]), true);

    dialog.show();
}
 
開發者ID:sztyler,項目名稱:sensordatacollector,代碼行數:23,代碼來源:TimePickerListener.java

示例9: setAlarm

import android.app.TimePickerDialog; //導入方法依賴的package包/類
@Subscribe
public void setAlarm(OnAlarmClickEvent event) {
    arrivalTime = event.arrivalTime;
    alarmTime = event.arrivalTime;
    int reminder = Integer.parseInt(sharedPreferences.getString(getString(R.string.pref_key_alarm_reminder), "5"));
    alarmTime = alarmTime.minusMinutes(reminder);

    TimePickerDialog timePickerDialog = new TimePickerDialog(
            this,
            this,
            alarmTime.getHourOfDay(),
            alarmTime.getMinuteOfHour(),
            DateFormat.is24HourFormat(this)
    );
    timePickerDialog.setTitle(R.string.alarm_dialog_title);
    timePickerDialog.setMessage(getString(R.string.alarm_dialog_message_fmt, DateUtils.formatTime(arrivalTime)));
    timePickerDialog.show();
}
 
開發者ID:tjyu1040,項目名稱:GallyShuttle,代碼行數:19,代碼來源:ScheduleActivity.java

示例10: 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

示例11: 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

示例12: 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

示例13: onDialogClosed

import android.app.TimePickerDialog; //導入方法依賴的package包/類
@Override
protected void onDialogClosed(final boolean positiveResult) {
    if (positiveResult) {
        v.set(dp.getYear(), dp.getMonth(), dp.getDayOfMonth());
        cv.put(getKey(), v.getTimeInMillis());
        if (ul != null) {
            ul.onUpdateValue(this);
        }
        if (dt) {
            TimePickerDialog tpd = new TimePickerDialog(getContext(), this,
                    v.get(Calendar.HOUR_OF_DAY), v.get(Calendar.MINUTE), true);
            tpd.setTitle(getTitle());
            tpd.setCancelable(true);
            tpd.show();
        }
    }
}
 
開發者ID:felixb,項目名稱:callmeter,代碼行數:18,代碼來源:CVDatePreference.java

示例14: onClick

import android.app.TimePickerDialog; //導入方法依賴的package包/類
@Override
public void onClick(final View v) {
    switch (v.getId()) {
        case R.id.date:
            DatePickerDialog dpd = new DatePickerDialog(this, this, cal.get(Calendar.YEAR),
                    cal.get(Calendar.MONTH), cal.get(Calendar.DAY_OF_MONTH));
            dpd.show();
            break;
        case R.id.time:
            TimePickerDialog dtp = new TimePickerDialog(this, this,
                    cal.get(Calendar.HOUR_OF_DAY), cal.get(Calendar.MINUTE),
                    DateFormat.is24HourFormat(this));
            dtp.show();
            break;
        default:
            break;
    }
}
 
開發者ID:felixb,項目名稱:callmeter,代碼行數:19,代碼來源:AddLogActivity.java

示例15: pickNightTime

import android.app.TimePickerDialog; //導入方法依賴的package包/類
private void pickNightTime() {
    TimePickerDialog.OnTimeSetListener startTimeListener = (view, startHourOfDay, startMinuteOfDay) -> {
        TimePickerDialog timePickerDialogEnd = new TimePickerDialog(getActivity(), (view1, endHourOfDay, endMinuteOfDay) -> storeNightModeInterval(startHourOfDay * 60 + startMinuteOfDay, endHourOfDay * 60 + endMinuteOfDay), Settings.get().ui().getNightEndTime() / 60, Settings.get().ui().getNightEndTime() % 60, true);

        timePickerDialogEnd.setTitle(R.string.title_end_time);
        timePickerDialogEnd.show();
    };

    TimePickerDialog timePickerDialogStart = new TimePickerDialog(getActivity(), startTimeListener,
            Settings.get().ui().getNightStartTime() / 60, Settings.get().ui().getNightStartTime() % 60, true);
    timePickerDialogStart.setTitle(R.string.title_start_time);
    timePickerDialogStart.show();
}
 
開發者ID:PhoenixDevTeam,項目名稱:Phoenix-for-VK,代碼行數:14,代碼來源:PreferencesFragment.java


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