Android Calendar View for Date Picker

后端 未结 8 1015
粉色の甜心
粉色の甜心 2020-12-02 09:24

I\'m writing my first app, and I have a question about DatePicker.

My app requires the user to input a date. The most user-friendly way would be to popu

8条回答
  •  清歌不尽
    2020-12-02 10:06

    Try to use this component: https://github.com/truefedex/android-date-picker

    If you want to use it like popup write on your onclick:

    if (calendarPopup == null) {
      calendarPopup = new PopupWindow(getContext());
      CalendarPickerView calendarView = new CalendarPickerView(getContext());
      CalendarNumbersView calendar = (CalendarNumbersView) calendarView.findViewById(com.phlox.datepick.R.id.calendar);
      calendar.setShowDayNames(false);
      calendarView.setListener(onDateSelectionListener);
      calendarPopup.setContentView(calendarView);
      calendarPopup.setWindowLayoutMode(
            MeasureSpec.makeMeasureSpec(llCalendar.getWidth(), MeasureSpec.EXACTLY),
            ViewGroup.LayoutParams.WRAP_CONTENT);
      calendarPopup.setHeight(1);
      calendarPopup.setWidth(llCalendar.getWidth());
      calendarPopup.setOutsideTouchable(true);
    }
    calendarPopup.showAsDropDown(llCalendar);
    

提交回复
热议问题