出于某种原因,我必须创建一个自定义日历组件,其中包含针对日期的自定义视图-用于不同类型日期的不同视图-正常,事件等-从JSON加载年份配置等.
For one reason or another, I had to create a custom calendar component with custom views for days - different views for different types of dates - normal, events, etc - loading year configuration from JSON, etc.
但是我需要以滑动"左右动画的方式进行操作-就像在Android日历应用程序中一样.
But I need to do this "sliding" left and right animated - as it is in the android calendar application.
例如.我已经在网络上阅读了很多东西,但是仍然找不到有关如何使用GridView进行操作的提示.
for example. I've read a lot on the web, but I still cannot find any tips on how to do this with GridView.
使用GridView作为基类也许不是最好的主意. 任何帮助将不胜感激.
Maybe it was not the best idea to use GridView as a base class. Any help would be appreciated.
推荐答案我使用了以下变体:
- 已加载3页(0、1、2)的ViewPager.
- 在每个页面上,我都有一个GridView代表日历中的一个月.
第0页是上个月 在第1页是当前月份 在第2页是下个月
On page 0 is the previous month On page 1 is the current month On page 2 is the next month
在ViewPager适配器中,我将适配器用于3个Gridview.
In ViewPager adapter I used adapters for the 3 Gridviews.
最初,我将活动页面设置为1.
Initially I set active page to 1.
每次更改页面时,我都会重新计算上个月,当前月份和下个月的月份数据,然后将活动页面再次设置为1.
On each page change I recalculate the month data for previous, current and next month and set active page again to 1.
这样,我可以模拟类似无限"视图寻呼机的内容. 目前,我的任务没问题-滑动页面日历.
This way I simulate something like "infinite" view pager. For the moment it's ok for my task - sliding pages calendar.
更多推荐
GridView动画水平滑动
发布评论