本文整理匯總了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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
}
}
示例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;
}
}
示例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();
}