Android Calendar View

Android Calendar View is used to display and select dates of the calendar.

This tutorial was aimed to create a calendar view on Android Studio.

Firstly create a new project in Android Studio.

In your activity_main.xml use, this <CalenderView> tag to set calendar.

<CalendarView android:id="@+id/simpleCalendarView" android:layout_width="fill_parent" android:layout_height="fill_parent" />

Run the application and you will get below output.

android, calendarview

Now we will show the selected date of the calendar using Toast.

In class override method onSelectedDayChange(CalendarView, int ,int, int). So, your class will look like it.

package com.androidlearninghub.myapplication2;
import;import;import android.os.Bundle;import android.widget.CalendarView;import android.widget.Toast;
public class MainActivity extends AppCompatActivity {

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_main);
        CalendarView calendarView = findViewById(;        if (calendarView != null) {
            calendarView.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
                @Override                public void onSelectedDayChange(@NonNull CalendarView view, int year, int month, int dayOfMonth) {
                    // Note that months are indexed from 0. So, 0 means January, 1 means february, 2 means march etc.                    String msg = "Selected date is " + dayOfMonth + "/" + (month + 1) + "/" + year;                    Toast.makeText(MainActivity.this, msg, Toast.LENGTH_SHORT).show();                }
            });        }


Now run the application you will get output like this.

android, calendarview, toast
This was very basic for android calendar view. Please comment your views in the comment section.