Loading...

set selectable date but not minDate in CalendarView


I have a CalendarView. I want to set minDate, but in a state witch user can see date before minDate but can't select them and i want to be able to select date before minDate programmatically

this is my layout :

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">

<CalendarView
    android:id="@+id/calendar_view"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginStart="16dp"
    android:layout_marginTop="8dp"
    android:layout_marginEnd="16dp"
    android:layout_marginBottom="8dp"
    android:calendarViewShown="false"
    android:datePickerMode="calendar"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintHorizontal_bias="0.482"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

this is my java code :

CalendarView calendarView=findViewById(R.id.calendar_view);
Calendar calendar=Calendar.getInstance();
calendarView.setMinDate(calendar.getTimeInMillis());

i want to select for example a day in a month ago as default of CalendarView and user can see it

- - Source
comments powered by Disqus