Issue
I'm using the library https://github.com/kizitonwose/CalendarView
for creating a calendar in kotlin.
I'm trying to follow the readme but the problem is that the docs doesn't specify how the variable calendarView
is declared.
From the docs we add the following to the xml, which has the id calendarView
:
<com.kizitonwose.calendarview.CalendarView
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cv_dayViewResource="@layout/calendar_day_layout" />
It then goes on to show the usage:
calendarView.dayBinder = object : DayBinder<DayViewContainer> {
// Called only when a new container is needed.
override fun create(view: View) = DayViewContainer(view)
// Called every time we need to reuse a container.
override fun bind(container: DayViewContainer, day: CalendarDay) {
container.textView.text = day.date.dayOfMonth.toString()
}
}
Problem is that I don't see how calendarView
is defined. My thought was:
val calendarView: CalendarView = findViewById(R.id.calendarView)
But calendarView
does not have the attribute dayBinder
.
So my question is, what should I specify as the type of calendarView
?
ie:
val calendarView: <WHAT SHOULD BE HERE?> = findViewById(R.id.calendarView)
Or should it be defined a different way?
Options available for me to define calendarView
:
Solution
Your syntax is correct, but it's probably getting android.widget.CalendarView
. Add the import for the third party library to the top of the file and it should work.
import com.kizitonwose.calendarview.CalendarView
Answered By - Tyler V
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.