码迷,mamicode.com
首页 > 移动开发 > 详细

android ListView隐藏FooterView(headerView)

时间:2014-06-16 11:20:52      阅读:279      评论:0      收藏:0      [点我收藏+]

标签:android   class   blog   code   get   使用   

在安卓开发中,在使用listView时,我们会经常用到footerView或者headerView

给ListView添加的footer和header好多时候,会根据情况隐藏和显示。

因为footer和header使用删除和添加的方法总感觉不好。

而直接设置footer和header中的view为GONE时,虽然内容不显示了,但是这块区域还是会被占用。

经过各种方法测试,最后得出一个可以完美解决该问题的方法,如下代码:

this.footerLayout.setVisibility(View.GONE);
this.footerLayout.setPadding(0, -footerLayout.getHeight(), 0, 0);


意思就是把内容往上移动View的高度。

当然,在需要显示的时候,还要设置回来(做一个if  else处理即可)

this.footerLayout.setVisibility(View.VISIBLE);
this.footerLayout.setPadding(0, 0, 0, 0);

问题解决真的很但疼~~~~

android ListView隐藏FooterView(headerView),布布扣,bubuko.com

android ListView隐藏FooterView(headerView)

标签:android   class   blog   code   get   使用   

原文地址:http://blog.csdn.net/catoop/article/details/30103099

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!