Android 3.0 CalendarView

别说谁变了你拦得住时间么 提交于 2019-11-30 15:07:31

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/7027960/android-3-0-calendarview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!