0

Is it possible to get the value of the month from the displayed month in a calenderView? I have already tried...

calenderView1.setOnDateChangeListener(new OnDateChangeListener() {

        @Override
        public void onSelectedDayChange(CalendarView view, int year,
                int month, int day) {

            SimpleDateFormat df = new SimpleDateFormat("MMMM");
            String result = df.format(month);
            System.out.println(" MONTH IS " + result);
            monthshowing = result;
            System.out.println(" MONTH IS NOW " + monthshowing);
            button1.setText(monthshowing);


        }

    });

but this returns December as the monthshowing. Also as I continue to scroll December remains and OnDateChangeListener no longer responds.

SmulianJulian
  • 801
  • 11
  • 33
  • `onSelectedDayChange()` update date only when you select date from CalenderView. visit [SO - CalendarView onDateChangeListener](http://stackoverflow.com/questions/12641250/android-calendarview-ondatechangelistener) – Bharatesh May 28 '15 at 03:14

1 Answers1

0

you'll get callback only when date is selected but not for scrolling.. if you want callback when scrolling better to use

    DatePickerDialog p = new DatePickerDialog(this,null,2015,4,28){
        @Override
        public void onDateChanged(DatePicker view, int year, int month, int day) {
            //this method will called when you scroll 
            //do your stuff over here.
            super.onDateChanged(view, year, month, day);
        }
    };

Hope this helps for your requirement...

shobhan
  • 1,460
  • 2
  • 14
  • 28