如何隐藏在Android的列表视图中的项目 [英] How to hide an item in a listview in Android

查看:94
本文介绍了如何隐藏在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的列表视图中的项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆