问题:

I have a ListView that's using a custom adapter. I want to dynamically add/remove items from the ListView. I've tried everything inside the getView() method in my view adapter. I've tried doing setVisiblity(View.GONE) on the view I'm returning. And it in fact doesn't draw the view, but it still allocates space for the view and it's just a blank black space.

Is this even possible to set items in ListView invisible?

回复:

You need to call setVisiblity(View.GONE) on the returned view and all the views inside it. If you are reusing the convert view passed in you need to remember to call setVisiblity(View.VISIBLE) on all the views you want visible.

If you have a lot of invisible views you may need to set the divider height to 0 and add your own divider to the returned views. Otherwise the 'invisible' views will each have a visible divider and produce a noticeable gray line between visible views.

结论:

1) 将View控件设置成不可视。

2) 将View内部的控件设置不可视。

3) 在xml布局文件将ListView分隔条高度置为0,采用自定义的分隔条。

4) 将View内部的分隔条设置不可视。

5) 第一行分隔条不可视。

Making a view in a listview invisible android的更多相关文章

  1. Android_(控件)使用ListView显示Android系统SD卡的文件列表_02

    使用ListView显示Android SD卡中的文件列表 父类布局activity_main.xml,子类布局item_filelayout(一个文件的单独存放) 运行截图: 程序结构 <?x ...

  2. Android_(控件)使用ListView显示Android系统中SD卡的文件列表

    使用ListView显示Android SD卡中的文件列表 父类布局activity_main.xml,子类布局line.xml(一个文件的单独存放) 运行截图: 程序结构: <?xml ver ...

  3. 让 ListView 在 Android 可回弹

    说明:让 ListView 在 Android 可回弹. 适用:Delphi XE5 修改:找出 FMX.Platform.Android.pas 档案,并复制到自己的 Project 路径里,找到 ...

  4. android中View的GONE和INVISIBLE的原理

    废话只重复两句: GONE真的隐藏: INVISIBLE不可见但是预留了View的位置: 网上千篇一律的重复着这两句话并举着例子,并没有观察本质来作区分.查看源码后得知其区别希望广大朋友能够借鉴,源码 ...

  5. Android_(控件)使用ListView显示Android系统中联系人信息

    使用ListView显示手机中联系人的姓名和电话号码 父类布局activity_main.xml,子类布局line.xml(一个文件的单独存放) 运行截图: (避免泄露信息对部分地方进行了涂鸦O(∩_ ...

  6. no drawer view found with gravity RIGHT(Android实现侧滑菜单从右面滑出) 解决办法

    代码如下: <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width ...

  7. 我的Android进阶之旅------>ListView中android:cacheColorHint,android:listSelector属性作用 .

    ( 本文转载于:http://blog.csdn.net/stonecao/article/details/6216449) 自定义listview的时候,当你不使用android:cacheColo ...

  8. delphi xe6 让 ListView 在 Android 可回弹[根据龟山阿卍原创修改为xe6版本]

    Delphi XE6 找出 FMX.Platform.Android.pas 档案,并复制到自己的 Project 路径里,找到 GetScrollingBehaviour 函数,修改成如下: uni ...

  9. Android中View的事件分发机制——Android开发艺术探索笔记

    原文链接 http://sparkyuan.me/ 转载请注明出处 介绍 点击事件的事件分发就是对MotionEvent事件的分发过程.当一个MotionEvent产生了以后,系统须要把这个事件传递给 ...

随机推荐

  1. jsp&el&jstl mvc和三层架构

    jsp:java在html中插入java 一.JSP技术 1.jsp脚本和注释 jsp脚本:(翻译成servlet,源码位置apache-tomcat-7.0.52\work\Catalina\loc ...

  2. uwsgi 报MemoryError

    网站部署后,基本一天有时候几个小时就会502,查看uwsgi日志看到,一直在报MemoryError的错 之前以为是python版本的问题,说是32位的python最多支持2G,但查看了python版 ...

  3. nginx常用参数设置

    1)隐藏nginx header 版本号 使用curl -I http://www.10.0.3.46 会发现server那里显示版本号 在nginx.conf的http里添加参数server_tok ...

  4. HBase Filter

    Filter CompareFilter 是高层的抽象类,下面我们将看到他的实现类和实现类代表的各种过滤条件 RowFilter,FamliyFilter,QualifierFilter,ValueF ...

  5. direct3d

    DirectX for .Net procedure 1, install DXSDK  https://www.microsoft.com/en-us/download/details.aspx?i ...

  6. asterisk todo

    1, 如何让用户打一个密码才能继续外拨? 可以利用__9xxx那种做法 2,如何和onsip连起来? 3, 如何记录所有拨打记录?

  7. npx:npm包执行器

    npx 作用: 单次执行命令而不需要安装到本机 执行依赖包里的二进制文件 使用不同版本的 node 利用 npx 可以下载模块这个特点,可以指定某个版本的 Node 运行脚本.它的窍门就是使用 npm ...

  8. maven添加自定义jar

    mvn install:install-file -Dfile=自定义jar文件路径 -DgroupId=所属组 -DartifactId=项目名 -Dversion=版本 -Dpackaging=j ...

  9. ES Route

    在ElaticSearch里面,路由功能算是一个高级用法,大多数时候我们用的都是系统默认的路由功能,一个es索引可以分多个shard和每个shard又可以有多个replia,默认情况下,elastic ...

  10. Excel技巧--使用温度计图让目标与实际对比更明显

    如上图,有一业绩目标与实际值对比表格,我们可使用如上图右方的温度计图表来让数字对比更明显些. 做法: 1.选择该表格,点击插入-->柱形图,簇状柱形图. 2.右键点击图表“实际值”柱,点选“设置 ...