mCalendarView.setOnDayClickListener(new OnDayClickListener() {
    @Override
    public void onDayClick(EventDay eventDay) {
    // Log.e("Event",((MyEventDay) eventDay).getNote()+" <--");
    }
});


出现错误:

Cannot resolved method 'setOnDayClickListener(anonymous com.applandeo.materialcalendarview.listeners.OnDayClickListener)'


还有其他方法可以实现onDayClick()方法吗?

最佳答案

实施错误的类可能是您的问题

在您的布局xml

<com.applandeo.materialcalendarview.CalendarView
android:id="@+id/mCalendarView"
android:layout_width="match_parent"
android:layout_height="match_parent" />


在您的Activity

com.applandeo.materialcalendarview.CalendarView mCalendarView;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    calendarView = (com.applandeo.materialcalendarview.CalendarView) findViewById(R.id.mCalendarView);
...


设置setOnDayClickListener方法

mCalendarView.setOnDayClickListener(new OnDayClickListener() {
  @Override
  public void onDayClick(EventDay eventDay) {
     // Log.e("Event",((MyEventDay) eventDay).getNote()+" <--");
  }
});

08-17 10:04