如何隐藏在Android的列表视图中的项目

编程入门 行业动态 更新时间:2024-10-25 10:27:22
本文介绍了如何隐藏在Android的列表视图中的项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我知道,这个问题被问过,但我还没有看到这一个工作的答案。

I know, this question was asked before, but I haven't seen a working answer for it.

有没有办法隐藏在的ListView 部分项目在不改变源数据?

Is there any way to hide some items in a ListView without changing source data?

我想设置的项目,以走了知名度,也将不再显示,但保留该项目的地方还是有的。

I tried to set visibility of the item view to gone, it won't be displayed anymore, but the place reserved for this item is still there.

我还设置:

android:dividerHeight="0dp" android:divider="#FFFFFF"

但没有成功。

Without success.

推荐答案

您可以编写自己的ListAdapter或子类的现有之一。

You can either write your own ListAdapter or subclass one of the existing ones.

在你ListAdapter,你只会过滤掉不希望显示的项目通过为getCount将(),getItem()时和getItemId()适当返回修改后的值。

In your ListAdapter, you would simply filter out the items you do not want displayed by returning modified values for getCount(), getItem() and getItemId() as appropriate.

更多推荐

如何隐藏在Android的列表视图中的项目

本文发布于:2023-11-16 19:55:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1607242.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   项目   列表   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!