0

I want to call an asynctask on change of a date. So I am using the following code which is working fine. But some unexpected things are happening here.

CalendarView cv = (CalendarView) root.findViewById(R.id.calendarView1);
cv.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
        @Override
        public void onSelectedDayChange(CalendarView view, int year, int month,
                int dayOfMonth) {

            //Toast.makeText(getActivity(), mont + "/"+dayOfMonth + "/" + year,     Toast.LENGTH_SHORT).show();

             EventsTask gt = new EventsTask(getActivity(), eventsList);
             gt.execute();

        }
    });

But this is also being called on change of month in calendar view which loads the same date. What needs to be done here so that I can stop this from happening.

nitin
  • 571
  • 1
  • 4
  • 16
  • why -ve points man....I just can't figure what's going on....Did you even read the question....u might be some genius if you can solve every problem...what a way to reply back..kudos.. – nitin Feb 07 '14 at 22:35

1 Answers1

0

For posterity's sake, Djomla1989 suggested a solution to this problem in this thread. onSelectedDayChange will be called when scrolling to a different month, even though the CalendarView's selected date doesn't change without clicking on a date. One must store the original selected date and determine if a new date was actually clicked on.

Community
  • 1
  • 1