我正在使用Material CalendarView的修改版本,这在我调用onCreate方法时会导致大量加载问题
setContentView(R.layout.content_calendar);
This is my code in its entirety.
有人知道我如何优化代码吗?到目前为止,我已经确定很多问题可能来自这些方法:
CalendarGridView.java:
//This method is needed to get wrap_content height for GridView
@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
}
CalendarViewPager.java:
//This method is needed to get wrap_content height for ViewPager
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height = 0;
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int h = child.getMeasuredHeight();
if (h > height){
height = h;
}
}
if (height != 0) {
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}