zoukankan      html  css  js  c++  java
  • Making a view in a listview invisible android

    问题:

    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) 第一行分隔条不可视。

  • 相关阅读:
    WDA学习(14):Colors Cell and Input Enable to ALV Column
    JavaScript try-catch语句(错误处理)
    constructor
    input file 重复上传同一张图片失效的解决办法
    input下拉带输入框
    box-shaw四边阴影详解
    苹方字体合集
    两个div不同高度并排显示
    弹窗库
    webstorm破解安装版本
  • 原文地址:https://www.cnblogs.com/janehlp/p/5755179.html
Copyright © 2011-2022 走看看