大家好,我有一个DatePickerRange
与材料设计,一切都是完美的工作
CalendarConstraints.Builder constraitBuilder = new CalendarConstraints.Builder();
constraitBuilder.setStart(mesPresente);
constraitBuilder.setEnd(limitDate);
// selectedPair = new Pair<>(today,); Selecionar da por default in DateRangePicker
//Date Range Picker
MaterialDatePicker.Builder<Pair<Long, Long>> builder = MaterialDatePicker.Builder.dateRangePicker();
builder.setTitleText("Seleciona a data");
//builder.setSelection(selectedPair);
builder.setCalendarConstraints(constraitBuilder.build()); // Delemita calendario apenas no ano atual
final MaterialDatePicker materialDatePicker = builder.build();
txtCalendar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
materialDatePicker.show(getActivity().getSupportFragmentManager(),"DATE_PICKER");
}
});
materialDatePicker.addOnPositiveButtonClickListener(new MaterialPickerOnPositiveButtonClickListener() {
@Override
public void onPositiveButtonClick(Object selection) {
txtCalendar.setText(materialDatePicker.getHeaderText())
}
});
字符串
我现在很想数一数,究竟是选择了多少天,即选择了多少天呢?
目前我不知道如何得到这些信息.
2条答案
按热度按时间vql8enpb1#
感谢Gabriele Mariotti感谢您的帮助,这是非常有价值的,我设法达成了一个解决方案,
字符串
nszi6y052#
更改您的
OnPositiveButtonClickListener
:字符串