Android日期与时间选择控件使用记录

 

日期选择

    private void showDatePickDialog(Activity activity, final TextView tv, final Calendar calendar) {
        new DatePickerDialog(
                activity,
                new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
                        calendar.set(year, month, dayOfMonth);
                        tv.setText(getFormattedDateString(calendar));
                    }
                },
                calendar.get(Calendar.YEAR),
                calendar.get(Calendar.MONTH),
                calendar.get(Calendar.DAY_OF_MONTH))
                .show();
    }

 

时间选择

    private void showTimePickDialog(Activity activity) {
        new TimePickerDialog(activity, new TimePickerDialog.OnTimeSetListener() {
            @Override
            public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                settingValues.alarmHour = hourOfDay;
                settingValues.alarmMinute = minute;
                settingValues.saveValues();
                mRemindAlarmPreference.setSubtitleText(generateAlarmTimeString(hourOfDay, minute));
                if (settingValues.alarmEnabled) {
                    setAlarm(true, settingValues.alarmHour, settingValues.alarmMinute);
                }
            }
        }, settingValues.alarmHour, settingValues.alarmMinute, true).show();
    }

 

Android日期与时间选择控件使用记录

上一篇:IOS报错Distill failed for unknown reasons.Assets.xcassets解决方法


下一篇:android NDK – 使独立工具链失败