如何当其虚张声势的ListView的头虚张声势、ListView

由网友(余生勿扰)分享简介:我开发了下面的屏幕彼此相邻的fourboxes的按钮。在点击按钮的,我改变列表视图的适配器。The fourboxes next to each other are buttons. On clicking of the buttons I am changing the adapter of the listvie...

我开发了下面的屏幕

彼此相邻的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 ?

编辑:请参阅我先前的问题在这里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.

阅读全文

相关推荐

最新文章