如何自定义日期选择器?

时间:2018-09-30 10:31:25

标签: android datetimepicker timepicker android-timepicker

我正在创建一个约会预订应用程序,我希望用户在其中选择上午9点至下午1点之间的时间或选择4:30 pm至10pm之间的时间。 下午1点至4.30点之间的时间是休息时间。 我已经验证了日期选择器,但是无法验证时间选择器。 请帮忙。 预先感谢。

 CheckBox cb1;
    Button submit,cal_date;
    DatePicker calender;

    int day,month,year,hour, minute;
    int day_final,month_final,year_final,hour_final, minute_final;

        Calendar c = Calendar.getInstance();
        hour = c.get(Calendar.HOUR_OF_DAY);
        minute = c.get(Calendar.MINUTE);

TimePickerDialog timePickerDialog = new TimePickerDialog(this,Select_Date_And_Time.this,
                hour,minute, DateFormat.is24HourFormat(this));
        timePickerDialog.show();

    public void onTimeSet(TimePicker timePicker, int i, int i1)
    {
        cb1.setVisibility(View.VISIBLE);

        hour_final = i;
        minute_final = i1;




         n5 =
                //"Year Selected Is: "  + year_final + "\n"+
                ("Date: " +day_final + "/"+
                        + month_final + "\n"+
                                "Time: "  + hour_final + ":"+ + minute_final);




        SharedPreferences.Editor editor = sharedpreferences.edit();
        editor.putString(detail, n5);
        editor.commit();

0 个答案:

没有答案