title: Xamarin - Java Library Listeners and Events?
body: <p>I'm trying to access user-defined listeners in this <a href="https://github.com/giuseppenovielli/Xamarin.Android-CompactCalendarView" rel="nofollow noreferrer">Android library with Xamarin bindings</a> (original <a href="https://github.com/SundeepK/CompactCalendarView" rel="nofollow noreferrer">here</a>) for when the calendar is scrolled to another month or a date is selected on the calendar.</p>
  
  <p>The listeners in the code given in the sample are as follows:</p>
  
  <pre><code>        compactCalendarView.setListener(new CompactCalendarView.CompactCalendarViewListener() {
          @Override
          public void onDayClick(Date dateClicked) {
              List&lt;Event&gt; events = compactCalendarView.getEvents(dateClicked);
              Log.d(TAG, "Day was clicked: " + dateClicked + " with events " + events);
          }
  
          @Override
          public void onMonthScroll(Date firstDayOfNewMonth) {
              Log.d(TAG, "Month was scrolled to: " + firstDayOfNewMonth);
          }
      });
  </code></pre>
  
  <p>Specifically what I'd like to access is the onDayClick listener.  The code for it in its Controller class in Java doesn't specify a button but rather calculates the position in the calendar of the date you clicked and then returns a date based on that calculation.</p>
  
  <pre><code>    void onSingleTapUp(MotionEvent e) {
  
      // Don't handle single tap when calendar is scrolling and is not stationary
  
      if (isScrolling()) {
  
          return;
  
      }
  
  
  
      int dayColumn = Math.round((paddingLeft + e.getX() - paddingWidth - paddingRight) / widthPerDay);
  
      int dayRow = Math.round((e.getY() - paddingHeight) / heightPerDay);
  
  
  
      setCalenderToFirstDayOfMonth(calendarWithFirstDayOfMonth, currentDate, monthsScrolledSoFar(), 0);
  
  
  
      int firstDayOfMonth = getDayOfWeek(calendarWithFirstDayOfMonth);
  
  
  
      int dayOfMonth = ((dayRow - 1) * 7) - firstDayOfMonth;
  
      if (isRtl) {
  
          dayOfMonth +=  6 - dayColumn;
  
      } else {
  
          dayOfMonth += dayColumn;
  
      }
  
      if (dayOfMonth &lt; calendarWithFirstDayOfMonth.getActualMaximum(Calendar.DAY_OF_MONTH)
  
              &amp;&amp; dayOfMonth &gt;= 0) {
  
          calendarWithFirstDayOfMonth.add(Calendar.DATE, dayOfMonth);
  
  
  
          currentCalender.setTimeInMillis(calendarWithFirstDayOfMonth.getTimeInMillis());
  
          performOnDayClickCallback(currentCalender.getTime());
  
      }
  
  }
  </code></pre>
  
  <p>Attempting to declare a listener as <code>CompactCalendarView.ICompactCalendarViewListener listener;</code> seems to declare it fine, but attempting to assign it a new CompactCalendarViewListener() gives me an "Undefined function" error.  </p>
  
  <p>I understand C# uses events instead of listeners, but I don't know how it handles user-defined listeners in Java libraries, or how to override events such as onDayClick/onMonthScroll.  </p>
  
  <p>Any help is greatly appreciated!</p>