当前位置: 首页>>代码示例>>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;未经允许,请勿转载。