Android的列表视图:页眉和页脚的意见 [英] android listviews: header and footer views

查看:140
本文介绍了Android的列表视图:页眉和页脚的意见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我ListActivity,我需要的页眉和页脚的意见(顶部和列表的底部)用作previous页和下页按钮,我的名单上,分别因为我希望只显示20个项目在时间

In my ListActivity, I need header and footer views (on the top and bottom of the list) to be used as previous page and next page buttons on my list, respectively, because I want to display only 20 items at a time.

我把我的头和脚的意见做:

I set my header and foot views by doing:

getListView().addHeaderView(myHeaderView);
getListView().addFooterView(myFooterView);
setListAdapter(adapter);

这工作得很好,但我需要动态地删除和添加这些页眉和页脚的观点,因为一些网页我的清单可能不会有下一个网页按钮或previous页面按钮。

This works fine, but I need to dynamically remove and add these header and footer views, because some pages of my list may not have a next page button or a previous page button.

现在的问题是,我不能叫addHeaderView或addFooterView后,我已经叫setListAdapter。

The problem is, I cannot call addHeaderView or addFooterView after I have called setListAdapter.

有没有解决的办法吗?

推荐答案

为什么不垮的页眉和页脚到零高度,或者是灰色不可用的按钮(甚至更好)。

Why not just collapse the header and footer to zero height, or gray out the buttons (even better).

和最佳的用户体验,在我看来,将是动态加载多个项目需要时(即在滚动),像内置的Gmail应用程序一样。

And the best user experience, in my opinion, would be to dynamically load more items when needed (i.e. upon scroll), like the built-in Gmail app does.

这篇关于Android的列表视图:页眉和页脚的意见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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