private void initializeCalendar() {

    calendario.setOnDateChangedListener(listener);
    calendario.setShowOtherDates(MaterialCalendarView.SHOW_ALL);

    Calendar calendar = Calendar.getInstance();
    calendario.setSelectedDate(calendar.getTime());

    /*calendar.set(calendar.get(Calendar.YEAR), Calendar.JANUARY, 1);
    calendario.setMinimumDate(calendar.getTime());

    calendar.set(calendar.get(Calendar.YEAR), Calendar.DECEMBER, 31);
    calendario.setMaximumDate(calendar.getTime());*/

    calendar.getInstance();
    calendar.add(Calendar.DAY_OF_MONTH, -2);

    OneDayDecorator diaDecor = new OneDayDecorator();

    ArrayList<CalendarDay> dates = new ArrayList<>();
    CalendarDay cal = CalendarDay.from(calendar);

    dates.add(cal);

    // calendario.addDecorator(new EventDecorator(0xffcccccc, dates));
    diaDecor.setDate(new Date(calendar.getTimeInMillis()));
    calendario.addDecorator(diaDecor);
  }
Exemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    widget = (MaterialCalendarView) findViewById(R.id.calendar);
    widget.setShowOtherDates(MaterialCalendarView.SHOW_DEFAULTS);

    Calendar calendar = Calendar.getInstance();

    widget.setSelectedDate(calendar.getTime());
    widget.setSelectionColor(R.color.colorAccent);
    //
    //        widget.addDecorators(
    //                new MySelectorDecorator(this),
    //                oneDayDecorator
    //        );
    widget.setOnDateChangedListener(this);
    new ApiSimulator().executeOnExecutor(Executors.newSingleThreadExecutor());
  }
Exemplo n.º 3
0
 private void selectDate(final Date date) {
   mMaterialCalendarView.setCurrentDate(date);
   mMaterialCalendarView.setSelectedDate(date);
 }