安卓:自定义分隔符(甚至项目)中的ListView depening对项目的内容 [英] Android: custom separator (or even item) in ListView depening on content of item

查看:255
本文介绍了安卓:自定义分隔符(甚至项目)中的ListView depening对项目的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经与约含地设有评级信息项目一个ListView 距离到当前位置。

I've a ListView with items containing information about places with a rating and the distance to the current location.

该项目被分成两组:

  • 在第1组:500米范围内
  • 第2组:500米 - 1公里
  • 在第3组:1公里 - 1.5公里
  • ...

Withing这些群体中的项目由他们的等级排序。

Withing these groups the items are sorted by their rating.

现在我放出来,通过我的自定义适配器(延伸 BaseAdapter )进入的ListView ,其中工程这些项目完美。

Now I put out these items via my custom adapter (extension of BaseAdapter) into the ListView, which works perfectly.

不过,我想要做的就是把分隔每个组的每个第一个项目之前。该分隔符可以是的TextView 说如500米 - 1公里的后跟该组中所有的的ListView 项目

However, what I'd like to do is to put a separator before the each first item of each group. This separator can be a TextView saying e.g. 500m - 1km followed by all the ListView items in that group.

在如何实现这个你知道吗?

Any idea on how to realize this?

推荐答案

这是一个实现这不正是你描述。

这一个是GPLv3的,因为它是从派生这个实现,这是GPLv3的。

That one is GPLv3, because it is derived from this implementation, which was GPLv3.

您也可以使用我的 MergeAdapter 了解这一点,这有被Apache许可证2.0的优势。只需把它交替组头的TextView 适配器含S的内容的每个部分的价值。

You can also use my MergeAdapter for this, which has the advantage of being Apache License 2.0. Just hand it an alternating set of header TextViews and Adapters containing each section's worth of content.

或者,你可以偷看所有这些并推出他们的行为到现有的适配器类。关键是要回报你的的TextView 头在正确的位置,并正确地实现像方法getViewTypeCount() getItemViewType() areAllItemsEnabled()的IsEnabled()

Or, you can peek at all of these and roll their behaviors into your existing Adapter class. The trick is to return your TextView headers at the right spot, and properly implement methods like getViewTypeCount(), getItemViewType(), areAllItemsEnabled(), and isEnabled().

这篇关于安卓:自定义分隔符(甚至项目)中的ListView depening对项目的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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