'How to use this Android Week View Library
I'm trying to implement on my android application a calendar week view where I will show all the events in that week like a school schedule. After searching for a while I found this library that seems to work: https://github.com/thellmund/Android-Week-View/wiki but I can't understand how I can add events on it.
This is the sample code that it's on their github:
data class MyEvent(
val id: Long,
val title: String,
val startTime: Calendar,
val endTime: Calendar
)
class BasicViewModel : ViewModel() {
private val _events = MutableLiveData<List<MyEvent>>()
val events: LiveData<List<MyEvent>> = _events
// ...
}
class BasicActivity : AppCompatActivity() {
private val viewModel by viewModels<BasicViewModel>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_basic)
val adapter = MyCustomPagingAdapter<Event>()
weekView.adapter = adapter
viewModel.events.observe(this) { events ->
adapter.submitList(events)
}
}
}
What should I do to add an event on it? Thanks for your help
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
