显示效果
第一次进入 如下正常:
没问题 但是 我来回切换的时候 数据是有的 但界面显示为空 如下:
最后发现 原因虽然比较简单 但是代价有点大
这是代码不好习惯引起的
修改点如下(注释部分为源代码 , 注释后面为修改代码):
protected void onLayout(boolean changed, int l, int t, int r, int b) {
super.onLayout(changed, l, t, r, b);
if (changed && !loadOnce) {
scrollViewHeight = getHeight();
scrollLayout = getChildAt(0);
firstColumn = (LinearLayout) findViewById(R.id.first_column);
secondColumn = (LinearLayout) findViewById(R.id.second_column);
spacing10 =UnitConversionUtil.getSizewithpx(20);
// LinearLayout.LayoutParams llfirst = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT);
// LinearLayout.LayoutParams llsecond = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT);
// firstColumn.setLayoutParams(llfirst);
// secondColumn.setLayoutParams(llsecond);
firstColumn.getLayoutParams();
secondColumn.getLayoutParams();
((LinearLayout.LayoutParams) firstColumn.getLayoutParams()).setMargins(0, spacing10, 0, spacing10);
((LinearLayout.LayoutParams) secondColumn.getLayoutParams()).setMargins(0, spacing10, 0, spacing10);
columnWidth = firstColumn.getWidth();
loadOnce = true;
}
}