0

I have an activity that shows a listview, the listview is contained within a fragment.

I now need to expand the view by adding a number of other listviews (essentially filters) on the existing listview.

I plan to use a tab construct, ideally all using the same fragment.

1) Is it possible for the same fragment to be referenced multiple times within one XML layouts, if so I assume each one will need a different tag.

2) Can the tabhost be set up in such a way that it can just use the same fragment and I can manage the adapter to perform the filtering.

Which would be the best method to use?

4

1 回答 1

0

使用ListFragment而不是将 ListView 放在 Fragment 中。然后你有一个适配器,你可以给你的物品。使用相同的adatper,因为我假设列表中的项目视图在应用过滤器后不会改变。

最后,使用SearchView并使用它的方法setOnQueryTextListener()来定义一个新的 Listener。在您的项目列表中应用您的过滤器。最后,将此过滤后的项目列表提供给您的适配器。

于 2013-03-31T23:28:06.257 回答