Android 3.0 日历视图
我正在尝试实现 CalendarView,它需要大量的时间(大约 10 秒)出现在屏幕上,它只加载月份和工作日标题,不显示任何日历内容。
使用此视频中的相同代码,但没有看到相同的结果。我试图在对话框中启动它:
CalendarView calendarView = new CalendarView(this); dialog.setContentView(calendarView);
但是,当我尝试将其嵌入到活动中时,屏幕花费了相同的时间来加载,并且同样无法正确显示。
I'm trying to implement a CalendarView, it takes an absurd amount of time (about 10 seconds) to appear on screen and it only loads the month and weekday headers, it does not display any calendar content.
Using the same code from this video but not seeing the same result. I'm trying to launch it in a dialog:
CalendarView calendarView = new CalendarView(this);
dialog.setContentView(calendarView);
but when I tried to embed it in an activity it took the screen the same amount of time to load and similarly failed to display correctly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
追踪有助于揭示 GregorianCalendar 被调用了数千次。
似乎当日历日不可见时,它会尝试计算所有日期而不仅仅是可见的日期。
通过显式设置
layout_width
和layout_height
解决了CalendarView仅显示标题信息的问题。wrap_content
或match_parent
均无法正常显示日历内容。The tracing helped reveal that GregorianCalendar was being called thousands of times.
It seems that when the calendar days aren't visible, it tries to calculate all of the dates rather than just the visible ones.
The issue of the CalendarView only displaying the header information was solved by setting the
layout_width
andlayout_height
explicitly. Neitherwrap_content
ormatch_parent
worked properly to display the calendar contents.