问题描述
我有活动,显示搜索结果。它扩展ListActivity。我需要显示在列表视图搜索结果划分几个项目。所以,我怎么添加分组到我的列表视图?
I have Activity for displaying search results. It extends ListActivity. I need to show search results in listview grouping several items. So, how do I add grouping to my listview?
推荐答案
你给你的的ListView
A ListAdapter
的知道如何做分组。
You give your ListView
a ListAdapter
that knows how to do the grouping.
这可能是覆盖 getViewTypeCount()
和 getItemViewType()
在适配器来形容其立场的问题得到这种种行,再加上修改 getView()
(或 NewView的()
和 bindView ()
为的CursorAdapter
)的需要。
This could be a matter of overriding getViewTypeCount()
and getItemViewType()
in the adapter to describe which positions get which sorts of rows, plus modifying getView()
(or newView()
and bindView()
for CursorAdapter
) as needed.
根据您从开始什么,你也许能够使用的东西,像我 MergeAdapter
代替。
Depending on what you are starting with, you might be able to use something like my MergeAdapter
instead.
这篇关于Android的列表视图组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!