0

Today I noticed that when you do a quick double drag in a ListView, the list will go to the end or the beginning of the list. It appears that this only happens in Samsung phones.

This has become an issue because I am adding JazzyListView animation effects to the elements on the list and they crash whenever this quick movement happens. (NullPointerException whenever the ListView.layoutChildren method is invoked)

Maybe I will need to modify the library, or is it any way to disable this ListView behavior?

4

1 回答 1

2

好吧,这种效果被称为“ DOUBLE FLING ”,每当我这样做时,它都会出现在 logcat 中,不幸的是,在 AbsListView 中,你唯一能做的就是设置摩擦力和速度比例。如果有人知道如何禁用该效果,那就太好了(但这可能不是解决此问题的最佳解决方案,因为用户可能熟悉该行为

我所做的(我的快速 + 肮脏的解决方案)是修改 JazzyListView 库,特别是 JazzyHelper 类,仅在应用动画之前验证该项目不为空:

           while (firstVisibleItem + indexAfterFirst < mFirstVisibleItem) {
                View item = view.getChildAt(indexAfterFirst);
                if(item != null) {
                    doJazziness(item, firstVisibleItem + indexAfterFirst, -1);
                }

                indexAfterFirst++;
            }

            int indexBeforeLast = 0;
            while (lastVisibleItem - indexBeforeLast > mLastVisibleItem) {
                View item = view.getChildAt(lastVisibleItem - firstVisibleItem - indexBeforeLast);

                if(item != null) {
                    doJazziness(item, lastVisibleItem - indexBeforeLast, 1);
                }

                indexBeforeLast++;

            }

我相信我应该修改有关实例属性 mFirstVisibleItem 的一些内容,否则快速滚动会删除显示项目的动画。但是,我的解决方案适用于任何想要快速解决此问题的人。

于 2013-07-15T07:35:30.167 回答