I am creating a custom calendar view for my Android application that allows me to scroll between months. I created custom calendar square views that I embedded in the custom calendar month, and everything works fine on a 1-month scale.
Sorry, I'm stuck now. Now I want to embed my own custom calendar views into the endless viewing of the pager so that I can endlessly scroll forward and backward through the calendar.
I tried adapting this horizontal pager to scroll endlessly with a simple trick. I keep an array of 3 of my calendar views and update the list based on where the user scrolls. Example...
- [July, August , September] (the focus is on August, then the user switches to September)
- [July, August, September ] (now the focus is on September).
- [August, August, September ] (shift in August remained one, rewrote July)
- [August, September, September ] (the shift in September remained one, rewrote August)
- [August, September , September] (set the view to mid-September so we center again)
- [August, September , October] (rewrite September 2 with the actual next month)
However, when I do this, a noticeable flash appears on the screen as I scroll to the next month.
Here is the forward scroll code (note: reverse scrolling has the same problem)
private void updateViewsForForwardScroll() {
I think the problem is that setCurrentScreen () ends before showMonth (currentMonth), so the view in INDEX_CURR is still updated when the screen is set. I tried to solve this using the following strategy instead ...
- [July, August , September] (the focus is on August, then the user switches to September)
- [July, August, September ] (now the focus is on September).
- [August, September ] (delete July, but save it for recycling)
- [August, September , October] (restart July to display October instead and add a view)
I have not touched the current focused view at all, but there is still a flash! This time, the screen flashes from September to August, and then until September.
So what am I doing wrong? Is there a way to do what I'm trying to do without knowing the user about it? If not, is there an existing class that I can use?
(As a side question, is it possible to customize Android CalendarView in any way visually? This will really solve all my problems ...)
Thanks in advance!
source share