本文整理汇总了Java中android.app.TimePickerDialog.OnTimeSetListener类的典型用法代码示例。如果您正苦于以下问题:Java OnTimeSetListener类的具体用法?Java OnTimeSetListener怎么用?Java OnTimeSetListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OnTimeSetListener类属于android.app.TimePickerDialog包,在下文中一共展示了OnTimeSetListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDialog
import android.app.TimePickerDialog.OnTimeSetListener; //导入依赖的package包/类
static Dialog createDialog(
Bundle args, Context activityContext, @Nullable OnTimeSetListener onTimeSetListener
) {
final Calendar now = Calendar.getInstance();
int hour = now.get(Calendar.HOUR_OF_DAY);
int minute = now.get(Calendar.MINUTE);
boolean is24hour = DateFormat.is24HourFormat(activityContext);
if (args != null) {
hour = args.getInt(TimePickerDialogModule.ARG_HOUR, now.get(Calendar.HOUR_OF_DAY));
minute = args.getInt(TimePickerDialogModule.ARG_MINUTE, now.get(Calendar.MINUTE));
is24hour = args.getBoolean(
TimePickerDialogModule.ARG_IS24HOUR,
DateFormat.is24HourFormat(activityContext));
}
return new DismissableTimePickerDialog(
activityContext,
onTimeSetListener,
hour,
minute,
is24hour);
}
示例2: NumberPadTimePickerDialogViewDelegate
import android.app.TimePickerDialog.OnTimeSetListener; //导入依赖的package包/类
NumberPadTimePickerDialogViewDelegate(@NonNull DialogInterface delegator,
@NonNull Context context, @NonNull NumberPadTimePicker timePicker,
@Nullable View okButton, @Nullable OnTimeSetListener listener, boolean is24HourMode) {
mDelegator = checkNotNull(delegator);
mTimePicker = checkNotNull(timePicker);
mOkButton = okButton;
mTimeSetListener = listener;
mDummy = new TimePicker(context);
// TODO: If this model is needed by other classes, make it a singleton.
final LocaleModel localeModel = new LocaleModel(context);
mPresenter = new NumberPadTimePickerDialogPresenter(this, localeModel, is24HourMode);
final OnBackspaceClickHandler backspaceClickHandler = new OnBackspaceClickHandler(mPresenter);
mTimePicker.setOnBackspaceClickListener(backspaceClickHandler);
mTimePicker.setOnBackspaceLongClickListener(backspaceClickHandler);
mTimePicker.setOnNumberKeyClickListener(new OnNumberKeyClickListener(mPresenter));
mTimePicker.setOnAltKeyClickListener(new OnAltKeyClickListener(mPresenter));
}
示例3: onCreateDialog
import android.app.TimePickerDialog.OnTimeSetListener; //导入依赖的package包/类
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Find the TaskEditFragment that created this dialog. We'll
// use that fragment as the edit callback, so that when the user
// chooses a new date in our datepicker dialog,
// the dialog will call back into the edit fragment to set the
// new date.
OnTimeSetListener listener = (OnTimeSetListener)
getFragmentManager()
.findFragmentByTag(
TaskEditFragment
.DEFAULT_FRAGMENT_TAG);
// Construct a new TimePicker Dialog that will be hosted by
// this fragment. Set its Hour and Minutes to the values
// specified in the args bundle
Bundle args = getArguments();
return new TimePickerDialog(getActivity(), listener,
args.getInt(HOUR),
args.getInt(MINS), false);
}
示例4: showTimePickerDialog
import android.app.TimePickerDialog.OnTimeSetListener; //导入依赖的package包/类
/**
* show timepicker
*
* @param mContext
* @param mTextView formar of the time
* @return show timepicker
*/
public static void showTimePickerDialog(final Context mContext,
final TextView mTextView) {
new TimePickerDialog(mContext, new OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
SimpleDateFormat timeFormatter = new SimpleDateFormat("hh:mm a");
dateTime.set(Calendar.HOUR_OF_DAY, hourOfDay);
dateTime.set(Calendar.MINUTE, minute);
mTextView.setText(timeFormatter.format(dateTime.getTime()));
}
}, dateTime.get(Calendar.HOUR_OF_DAY), dateTime.get(Calendar.MINUTE),
false).show();
}
示例5: setEventListeners
import android.app.TimePickerDialog.OnTimeSetListener; //导入依赖的package包/类
private void setEventListeners() {
saveAlert.setOnClickListener(onAlertSave());
alertEventSpinner.setOnItemSelectedListener(spinnerItemSelected());
editStartTime.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
TimePickerDialog tp1 = new TimePickerDialog(activity,
new OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view,
int hourOfDay, int minute) {
editStartTime.setText(hourOfDay + ":" + minute);
}
}, 00, 00, true);
tp1.show();
}
});
}
示例6: showTimeDialog
import android.app.TimePickerDialog.OnTimeSetListener; //导入依赖的package包/类
public void showTimeDialog() {
final Calendar cal = Calendar.getInstance();
// load preferences
SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity());
int hourOfDay = cal.get(Calendar.HOUR_OF_DAY);
int minute = cal.get(Calendar.MINUTE);
try {
hourOfDay = sharedPref.getInt("alarm_hour_of_day", Calendar.HOUR_OF_DAY);
minute = sharedPref.getInt("alarm_minute", Calendar.MINUTE);
} catch (Exception e) {
e.printStackTrace();
}
OnTimeSetListener timeSetListener = (OnTimeSetListener) this;
new TimePickerDialog(getActivity(), 0, timeSetListener, hourOfDay, minute, true).show();
}
示例7: pickDateTime
import android.app.TimePickerDialog.OnTimeSetListener; //导入依赖的package包/类
/**
* 日期和时间选择对话框,选选择日期后选择时间
*
* @param con 上下文
* @param title1 日期选择标题
* @param title2 事件选择标题
* @param calendar 默认日期
* @param listener 时间选择事件
*/
public static void pickDateTime(final Context con, String title1, final String title2, final Calendar calendar, final OnTimeSetListener listener) {
// 增加判断,解决4.X系统可能存在的弹出多个时间选择器的问题
final boolean[] isShowTime = {false};
pickDate(con, title1, calendar, new OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
calendar.set(year, month, dayOfMonth);
if (!isShowTime[0]) {
isShowTime[0] = true;
pickTime(con, title2, calendar, listener);
}
}
});
}
示例8: pickTime
import android.app.TimePickerDialog.OnTimeSetListener; //导入依赖的package包/类
/**
* 时间选择对话框
*
* @param con 上下文
* @param title 标题
* @param listener 选择事件
* @param cal 默认时间
*/
public static void pickTime(Context con, String title, Calendar cal, final OnTimeSetListener listener) {
LinearLayout ll = new LinearLayout(con);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
ll.setLayoutParams(layoutParams);
ll.setOrientation(LinearLayout.VERTICAL);
//添加一条线
LinearLayout line = new LinearLayout(con);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 1);
line.setBackgroundColor(con.getResources().getColor(R.color.line));
line.setLayoutParams(lp);
ll.addView(line);
//添加选择器控件
final TimePicker timePicker = new TimePicker(con, null, themeId);
timePicker.setLayoutParams(layoutParams);
timePicker.setCurrentHour(cal.get(Calendar.HOUR_OF_DAY));
timePicker.setCurrentMinute(cal.get(Calendar.MINUTE));
timePicker.setIs24HourView(true);
ll.addView(timePicker);
QuickDialog.Builder builder = new QuickDialog.Builder(con);
builder.setContentView(ll);
builder.setTitle(title);
builder.setPositiveButton(R.string.confirm, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
listener.onTimeSet(timePicker, timePicker.getCurrentHour(), timePicker.getCurrentMinute());
}
});
builder.create().show();
}
示例9: newInstance
import android.app.TimePickerDialog.OnTimeSetListener; //导入依赖的package包/类
public static NumberPadTimePickerDialogFragment newInstance(OnTimeSetListener listener,
@DialogMode int dialogMode, @StyleRes int themeResId, boolean customTheme) {
NumberPadTimePickerDialogFragment f = new NumberPadTimePickerDialogFragment();
Bundle args = new Bundle();
args.putInt(KEY_THEME_RES_ID, themeResId);
args.putInt(KEY_DIALOG_MODE, dialogMode);
args.putBoolean(KEY_CUSTOM_THEME, customTheme);
f.setArguments(args);
f.listener = listener;
return f;
}
示例10: setupDialogView
import android.app.TimePickerDialog.OnTimeSetListener; //导入依赖的package包/类
static void setupDialogView(@NonNull DialogView dialogView, @NonNull final Context context,
@NonNull final NumberPadTimePicker timePicker, @NonNull View okButton,
@Nullable final OnTimeSetListener listener, boolean is24HourMode) {
DialogPresenter presenter = new NumberPadTimePickerDialogPresenter(dialogView,
timePicker.getPresenter());
setupDialogView(dialogView, presenter, context, timePicker, okButton, listener,
is24HourMode);
}
示例11: NumberPadTimePickerDialog
import android.app.TimePickerDialog.OnTimeSetListener; //导入依赖的package包/类
public NumberPadTimePickerDialog(@NonNull Context context, @StyleRes int themeResId,
@Nullable OnTimeSetListener listener, boolean is24HourMode) {
super(context, resolveDialogTheme(context, themeResId));
final View root = getLayoutInflater().inflate(
R.layout.nptp_alert_numberpad_time_picker_dialog, null);
final NumberPadTimePicker timePicker = (NumberPadTimePicker)
root.findViewById(R.id.nptp_time_picker);
final NumberPadTimePickerAlertComponent timePickerComponent =
(NumberPadTimePickerAlertComponent) timePicker.getComponent();
final DialogPresenter presenter = new NumberPadTimePickerDialogPresenter(
this, timePicker.getPresenter());
DialogViewInitializer.setupDialogView(this, presenter, getContext(),
timePicker, timePickerComponent.getOkButton(), listener, is24HourMode);
timePickerComponent.getCancelButton().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
presenter.onCancelClick();
}
});
mThemer = new NumberPadTimePickerDialogThemer(timePickerComponent);
mIs24HourMode = is24HourMode;
// Must be requested before adding content, or get an AndroidRuntimeException!
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(root);
}
示例12: Bug34833WorkaroundTimePickerDialog
import android.app.TimePickerDialog.OnTimeSetListener; //导入依赖的package包/类
public Bug34833WorkaroundTimePickerDialog(Context context, OnTimeSetListener callBack, int hourOfDay, int minute, boolean is24HourView) throws NoSuchFieldException, IllegalAccessException, IllegalArgumentException {
super(context, null, hourOfDay, minute, is24HourView);
this.callBack = callBack;
//É obrigado a obter o timePicker desta forma porque o TimePickerDialog não possui um "getTimePicker" (ao contrário do DatePickerDialog).
Field field = TimePickerDialog.class.getDeclaredField("mTimePicker");
field.setAccessible(true);
timePicker = (TimePicker) field.get(this);
}
示例13: onCreateDialog
import android.app.TimePickerDialog.OnTimeSetListener; //导入依赖的package包/类
@Override
public Dialog onCreateDialog(Bundle savedInstanceState){
OnTimeSetListener listener = (OnTimeSetListener)
getFragmentManager().findFragmentByTag(TaskEditFragment.DEFAULT_FRAGMENT_TAG);
Bundle args = getArguments();
return new TimePickerDialog(getActivity(),listener,args.getInt(HOUR),args.getInt(MINS),false);
}
示例14: showTimeDlg
import android.app.TimePickerDialog.OnTimeSetListener; //导入依赖的package包/类
private void showTimeDlg(final TextView textView) {
TimePickerDialog pickdialog = new TimePickerDialog(mContext,
new OnTimeSetListener() {
@Override
public void onTimeSet(TimePicker view, int hourOfDay,
int minute) {
textView.setText(String.format("%02d:%02d", hourOfDay,
minute));
}
}, 0, 0, true);
pickdialog.show();
}
示例15: showDateTimeSelectors
import android.app.TimePickerDialog.OnTimeSetListener; //导入依赖的package包/类
/**
* Show date and time pickers
*/
protected void showDateTimeSelectors(long reminder) {
// Sets actual time or previously saved in note
final Calendar now = DateHelper.getCalendar(reminder);
DatePickerDialog mCalendarDatePickerDialog = DatePickerDialog.newInstance(
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePickerDialog dialog, int year, int monthOfYear, int dayOfMonth) {
reminderYear = year;
reminderMonth = monthOfYear;
reminderDay = dayOfMonth;
TimePickerDialog mRadialTimePickerDialog = TimePickerDialog.newInstance(
new TimePickerDialog.OnTimeSetListener() {
@Override
public void onTimeSet(RadialPickerLayout radialPickerLayout, int hour, int minute) {
hourOfDay = hour;
minutes = minute;
showRecurrencePickerDialog(recurrenceRule);
}
}, now.get(Calendar.HOUR_OF_DAY), now.get(Calendar.MINUTE),
DateHelper.is24HourMode(mActivity));
mRadialTimePickerDialog.show(mActivity.getSupportFragmentManager(), Constants.TAG);
}
}, now.get(Calendar.YEAR), now.get(Calendar.MONTH), now.get(Calendar.DAY_OF_MONTH));
mCalendarDatePickerDialog.show(mActivity.getSupportFragmentManager(), Constants.TAG);
}