Android 3.0 日历视图

发布于 2024-11-29 05:57:55 字数 496 浏览 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

十级心震 2024-12-06 05:57:55

追踪有助于揭示 GregorianCalendar 被调用了数千次。
似乎当日历日不可见时,它会尝试计算所有日期而不仅仅是可见的日期。

通过显式设置layout_widthlayout_height解决了CalendarView仅显示标题信息的问题。 wrap_contentmatch_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 and layout_height explicitly. Neither wrap_content or match_parent worked properly to display the calendar contents.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文