我有一个ListView.当用户一直滚动到底部时,它背后的数据是从10到30个项目的互联网中获取的.为了表明它正在加载更多项目,我曾经addFooterView()添加了一个简单的视图,显示"正在加载..."消息和一个微调器.现在,当我没有数据(没有更多数据要提取)时,我想要隐藏该消息.我试着这样做:
loadingView.setVisibility(View.GONE);
Run Code Online (Sandbox Code Playgroud)
不幸的是,虽然这确实隐藏了视图,但它为它留下了空间.即我最终得到一个大的空白区域,其中"加载"消息曾经是.我怎样才能正确隐藏这个视图?
我无法使用,removeFooterView()因为我可能需要再次显示它,在这种情况下我不能addFooterView()再次调用,因为已经设置了适配器ListView,并且在设置适配器后无法调用addHeaderView()/ addFooterView().
Yon*_*lan 37
尝试将页脚高度设置为0px或1px,然后再将其隐藏.或者,将页脚视图包裹在一个wrap_content高度中FrameLayout并隐藏/显示内部视图,使其保持FrameLayout可见; 高度应该适当包裹然后.
在我的情况下,addFooterView/removeFooterView()会导致一些文物.我找到了其他解决方案.我使用FrameLayout作为FooterView.当我想添加Footer时,我调用了mFrameFooter.addView(myFooter); 和mFrameFooter.removeAllViews(); 删除.
FrameLayout frameLayout = new FrameLayout(this);
listView.addFooterView(frameLayout);
......
......
//For adding footerView
frameLayout.removeAllViews();
frameLayout.addView(mFooterView);
//For hide FooterView
frameLayout.removeAllViews();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
38066 次 |
| 最近记录: |