Dialogplus:在DatePicker中切换月份和年份无效

时间:2019-10-14 14:27:06

标签: android android-datepicker dialogplus

我有DatePicker作为日历视图,它放在DialogPlus布局中。因此,问题在于选择器无法通过单击箭头(向左/向右)切换月份,并且年份选择也不起作用。有什么想法吗?

Issue on Github

<DatePicker
    android:id="@+id/pickerDate"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:datePickerMode="calendar"/>

方法:

private void openDialogDatePickup() {
    PickerDateBinding binding = PickerDateBinding.inflate(getLayoutInflater());
    datePicker = binding.pickerDate;
    // set datePicker options
    dialog = DialogPlus.newDialog(this)
            .setContentHolder(new ViewHolder(binding.getRoot()))
            .setExpanded(false)
            .setCancelable(true)
            .create();
    dialog.show();

}

1 个答案:

答案 0 :(得分:1)

您可以添加此库 点击here 然后您可以使用MonthDayPicker

 new DialogPlusBuilder().blurBackground()
                .buildMonthDayPickerDialog(Calendar.getInstance(),
                        (pickedMonth, pickedDay) ->{ //TODO implement your business}
                .show(getSupportFragmentManager(), "Month Day Picker");
相关问题