本文整理匯總了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();
}
示例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: 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;
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例10: newInstance
import android.app.TimePickerDialog; //導入方法依賴的package包/類
public static TimePickerFragment newInstance(
TimePickerDialog.OnTimeSetListener onTimeSetListener
) {
TimePickerFragment fragment = new TimePickerFragment();
fragment.onTimeSetListener = onTimeSetListener;
return fragment;
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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;
}
}