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


Java TimePickerDialog類代碼示例

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


TimePickerDialog類屬於android.app包,在下文中一共展示了TimePickerDialog類的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: pickTime

import android.app.TimePickerDialog; //導入依賴的package包/類
/**
 * 彈出時間選擇對話框
 * <p>
 * 參數:
 * title:標題
 * datetime 指定時間 yyyy-MM-dd HH:mm或者HH:mm
 * 返回:
 * time:格式:HH:mm
 */
public static void pickTime(IQuickFragment webLoader, WebView wv, JSONObject param, final Callback callback) {
    String title = param.optString("title");
    String date = param.optString("datetime");
    final Calendar calendar = Calendar.getInstance();
    if (!TextUtils.isEmpty(date)) {
        if (date.contains(" ")) {
            calendar.setTime(DateUtil.convertString2Date(date, "yyyy-MM-dd HH:mm"));
        } else {
            calendar.setTime(DateUtil.convertString2Date(date, "HH:mm"));
        }
    }
    DialogUtil.pickTime(webLoader.getPageControl().getActivity(), title, calendar, 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 chooseTime = DateUtil.convertDate(calendar.getTime(), "HH:mm");
            Map<String, Object> map = new HashMap<>();
            map.put("time", chooseTime);
            callback.applySuccess(map);
        }
    });
}
 
開發者ID:quickhybrid,項目名稱:quickhybrid-android,代碼行數:33,代碼來源:UIApi.java

示例6: pickDateTime

import android.app.TimePickerDialog; //導入依賴的package包/類
/**
 * 彈出日期時間選擇對話框
 * <p>
 * 參數:
 * title:標題
 * datetime 指定時間 yyyy-MM-dd HH:mm
 * 返回:
 * datetime:格式:yyyy-MM-dd HH:mm
 */
public static void pickDateTime(final IQuickFragment webLoader, WebView wv, JSONObject param, final Callback callback) {
    String title1 = param.optString("title1");
    String title2 = param.optString("title2");
    String date = param.optString("datetime");
    final Calendar calendar = Calendar.getInstance();
    if (!TextUtils.isEmpty(date)) {
        calendar.setTime(DateUtil.convertString2Date(date, "yyyy-MM-dd HH:mm"));
    }
    DialogUtil.pickDateTime(webLoader.getPageControl().getActivity(), title1, title2, calendar, 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 chooseDate = DateUtil.convertDate(calendar.getTime(), "yyyy-MM-dd HH:mm");
            Map<String, Object> map = new HashMap<>();
            map.put("datetime", chooseDate);
            callback.applySuccess(map);
        }
    });
}
 
開發者ID:quickhybrid,項目名稱:quickhybrid-android,代碼行數:30,代碼來源:UIApi.java

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

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

示例9: onCreateDialog

import android.app.TimePickerDialog; //導入依賴的package包/類
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Calendar c = Calendar.getInstance();
    int hour = c.get(Calendar.HOUR_OF_DAY);
    int minute = c.get(Calendar.MINUTE);

    return new TimePickerDialog(getActivity(), this, hour, minute, DateFormat.is24HourFormat(getActivity()));
}
 
開發者ID:segasunset,項目名稱:WeatherAlarmClock,代碼行數:10,代碼來源:EditAlarmActivity.java

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

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

示例12: displayTimePicker

import android.app.TimePickerDialog; //導入依賴的package包/類
private void displayTimePicker(final EditText destination) {
    TimePickerFragment timePickerFragment = new TimePickerFragment();
    timePickerFragment.setOnTimeSetListener(new TimePickerDialog.OnTimeSetListener() {
        @Override
        public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
            Calendar calendar = Calendar.getInstance();
            calendar.set(calendar.HOUR_OF_DAY, hourOfDay);
            calendar.set(Calendar.MINUTE, minute);
            String displayTime = simpleTimeFormat.format(calendar.getTime());
            destination.setText(displayTime);
            switch (destination.getId()) {
                case R.id.ane_start_time:
                    newEventPresenter.setStartTime(hourOfDay, minute);
                    break;
                case R.id.ane_end_time:
                    newEventPresenter.setEndTime(hourOfDay, minute);
                    break;
            }
        }
    });
    timePickerFragment.show(getSupportFragmentManager(), TimePickerFragment.TAG);
}
 
開發者ID:macoscope,項目名稱:RoomBookerMVP,代碼行數:23,代碼來源:NewEventActivity.java

示例13: showTimePicker

import android.app.TimePickerDialog; //導入依賴的package包/類
private void showTimePicker(final boolean startTime) {
    final Calendar dateTime = startTime ? mEvent.localStart : mEvent.localEnd;
    new TimePickerDialog(getContext(),
            new TimePickerDialog.OnTimeSetListener() {
                @Override
                public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                    dateTime.set(Calendar.HOUR_OF_DAY, hourOfDay);
                    dateTime.set(Calendar.MINUTE, minute);
                    mSwitchAllDay.setChecked(false);
                    setTime(startTime);
                }
            },
            dateTime.get(Calendar.HOUR_OF_DAY),
            dateTime.get(Calendar.MINUTE),
            false)
            .show();
}
 
開發者ID:tortuvshin,項目名稱:yield,代碼行數:18,代碼來源:EventEditView.java

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

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


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