如何隐藏一个ListView项目

如何隐藏一个ListView项目

本文介绍了Android的:如何隐藏一个ListView项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ListView你怎么能隐藏的项目,或至少将其高度为零?

How can you hide an item in a ListView or at least set its height to zero?

我已经尝试设置查看到GONE的知名度,但它仍然保持着该项目的空间(高度)。

I have tried setting the visibility of the View to GONE but it still maintains the item's space (height).

推荐答案

Ressurecting一个老问题,但我只是有这个问题,我想暂时隐藏根据列表数据之外的标准列表项。最后我做什么是创建一个XML格式的空项目的布局,并返回根据我的标准,而不是在getView()...

Ressurecting an old question, but I just had this issue where I wanted to hide list items temporarily based upon criteria outside of the list data. What I ended up doing was creating a "null item" layout in xml and returned that based upon my criteria instead of the convert view in getView()...

,我回到我的null_item ...

instead of returning the convertView, I returned my null_item...

return inflater.inflate(R.layout.null_item, null);

null_item.xml:

null_item.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

</LinearLayout>

这篇关于Android的:如何隐藏一个ListView项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 01:23