如何当其虚张声势的ListView的头 [英] How to show header of ListView when its empty

查看:131
本文介绍了如何当其虚张声势的ListView的头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了下面的屏幕

彼此相邻的fourboxes的按钮。在点击按钮的,我改变列表视图的适配器。

The fourboxes next to each other are buttons. On clicking of the buttons I am changing the adapter of the listview.

由于列表视图上面的内容占去了很大的空间,我做了整个事情作为一个头,并通过code增加了。

Since the content above the listview took up lot of space I made the whole thing as an header and added it via code.

   myPollsList = (ListView) findViewById(R.id.listArea);
myPollsList.addHeaderView(getLayoutInflater().inflate(R.layout.profile_listview_header, null));

现在我想告诉一些人认为,当列表为空。但是,如果我这样做,那么标题也消失。

Now I want to show some view when the list is empty. But if I do that then the header also goes away.

我在一个活动,而不是一个ListActivity用本品。任何建议或解决方法显示的标题,即使该列表是空的?

I am using this in a Activity and not a ListActivity. Any suggestions or workarounds for showing the header even when the list is empty ?

编辑:请参阅我先前的问题在这里<一href="http://stackoverflow.com/questions/17976497/listview-not-getting-space-to-show-content-on-smaller-screens">ListView没有得到的空间显示在小屏幕的内容。这是有人建议我通过将其作为标题

Refer to my earlier question here ListView not getting space to show content on smaller screens . This is where someone suggested me to solve the problem by putting it as a header

推荐答案

这就是我是如何解决它。我不得不将其连接到ListView自定义适配器。当它发现,它有为零的项目显示。这将增加一个假的空视图作为一个项目到列表中。

So this is how I solved it. I had a custom adapter which was connected to the listview. When it found that it had zero items to display. It would add a fake empty view as an item to the list.

这篇关于如何当其虚张声势的ListView的头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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