Articles → ANDROID → CalendarView In Android

CalendarView In Android






What Is Calendarview?





Example




  1. Display a calendar view
  2. On select of any date, display the selected date in the textbox.


Picture showing the calendar view and a textbox in an android application
Click to Enlarge



CalendarView dp = (CalendarView) findViewById(R.id.dpPicker);

dp.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {

    @Override
    public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
        TextView textView = (TextView) findViewById(R.id.tvGetDate);
        textView.setText(String.valueOf(year) +
            "-" + String.valueOf(month) + "-" + String.valueOf(dayOfMonth));
    }
});




Picture showing the output of the calendar view control in android
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Sunday, November 24, 2019

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250