ListView控件与节头的问题 [英] ListView with section header problem

查看:142
本文介绍了ListView控件与节头的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好我添加部分标题为我的ListView,还有网络上的一些方法。由于我使用simpleCursorAdapter来管理我的ListView,我采用了菲尔·博格尔的方法。 http://thebogles.com/blog/2010/02/科头换Android的列表视图/

Hi I'm adding section headers for my listView, there are few methods on the web. Since I'm using simpleCursorAdapter to manage my listView, I adopted phil bogle's method. http://thebogles.com/blog/2010/02/section-headers-for-android-listviews/

    listAdapter.setViewBinder( new SimpleCursorAdapter.ViewBinder()
    {
        public boolean setViewValue(View view, Cursor cursor, int
                                   columnIndex)
        {
              if (columnIndex == nDateIndex) {
                if (isHeaderVisible(cursor)) {
                    view.setVisibility(View.VISIBLE);
                     prevDate = dateString;
                    ((TextView) view).setText(dateString);
                } else {
                    ((TextView) view).setText("");
                    view.setVisibility(View.GONE);
                }
                return true;
            }
            return false;
        }
    });

这是LogCat中显示他们如何比较,而我向上滚动列表:

This is the LogCat shows how they compare while I scroll up the list:

09-06 11:06:43.460: INFO/System.out(563): Sun, 05 Sep 2010 11:41:53  (dateString)
09-06 11:06:43.460: INFO/System.out(563): Wed, 01 Sep 2010 21:58:06  (preDate)
09-06 11:06:43.460: INFO/System.out(563): 120.0                      (record)
09-06 11:06:43.820: INFO/System.out(563): Sun, 05 Sep 2010 17:47:26  (dateString)
09-06 11:06:43.820: INFO/System.out(563): Sun, 05 Sep 2010 11:41:53  (preDate)
09-06 11:06:43.820: INFO/System.out(563): 112.0                      (record)

正确的输出应该是:结果
     孙,2010年9月5日结果
      112结果
     120

但是,当我向上滚动,则调用setViewValue第120和preDATE(显示以上)相比,它变成了:结果
    孙,2010年9月5日结果
    112结果
    太阳,2010年9月5日结果
    120

But when I scroll up, the setViewValue calls 120 first and compare with preDate(show above), it becomes:
Sun, 05 Sep 2010
112
Sun, 05 Sep 2010
120

那么,怎样才能让我创建固定头后段头?为什么滚动时setViewBinder被称为?对此有什么建议?谢谢!

So how can I make the section headers fixed after creating the headers? Why setViewBinder been called while scrolling? Any suggestions on this? Thanks!

推荐答案

您也可以看看这里很简单的项目:的 HTTP://$c$c.google.com/p/android-section-list/ 。灵感来自于iOS版的部分名单出来(出来,在iOS上的框)。

You might also take a look at very simple project here: http://code.google.com/p/android-section-list/. Inspiration came from iOS's section list (comes out of the box in iOS).

这篇关于ListView控件与节头的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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