EverythingMe / overscroll-decor

Android: iOS-like over-scrolling effect applicable over almost all scrollable Android views.
BSD 2-Clause "Simplified" License
2.85k stars 400 forks source link

When scrolling listview ,item's click event will do work . How to deal it ? Thanks! #3

Closed qianyukun closed 8 years ago

d4vidi commented 8 years ago

Are you saying the 'onClick' callbacks on list items are invoked while over-scrolling?

d4vidi commented 8 years ago

Hey, just looked into that and didn't get onClick events. Could you please elaborate on the use-case and the actual problem? Thanks!!!

qianyukun commented 8 years ago

I have a listView to show message. The 'onClick' callbacks on list items are invoked while over-scrolling.

d4vidi commented 8 years ago

qianyukun thanks so much for this submission! I have indeed found the bug you've described when using ListView's setOnItemClickListener(). Fortunately, it can be easily fixed -- I'll get that done in my next release. In the meantime, here are two alternatives you can go by:

  1. Work-around: instantiate a single click listener and register it to each of the ListView item views, separately, by using view.setOnClickListener(). Use it instead of the global list item click listener you currently have.
  2. Fix the bug yourself: fork the project, edit OverScrollBounceEffectDecoratorBase.java, jump to line #250 and change the return value to 'true'. This would cause the 'touch-up' event to be consumed by the over-scroller rather than transferred to the ListView itself. Of course this means you will have to compile the project locally (e.g. using 'compile project(':overscroll')' in build.gradle - let me know if you need help).
qianyukun commented 8 years ago

Thank you ! I have fixed the problem.

d4vidi commented 8 years ago

I have fixed and pushed the issue -- will be included in the next lib release. Thanks again!

harolhiguera commented 7 years ago

Hi d4vidi, I know this issue has been closed a while ago but I still have the problem mentioned here while I implement it in a ListView, when I swipe the listview up so it bounces the list view item receives the click event. How could I avoid it? Im using the version 1.0.4. I would really appreciate some advice regarding this one, Thanks.

vellov commented 7 years ago

I have same problem as harolhiguera

d4vidi commented 7 years ago

Great, maybe that would help me get to the bottom of this! :-) Are you assigning explicit listeners on each view or do you use ListView's setOnItemClickListener()? I added the former technique to the demo project in this commit and it seems to be working well - wondering about the latter...

kirikaTowa commented 3 years ago

qianyukun 非常感谢您的提交!我确实发现了您在使用 ListView 的 setOnItemClickListener() 时所描述的错误。幸运的是,它可以轻松修复——我将在我的下一个版本中完成。 同时,您可以选择以下两种选择:

  1. 解决方法:使用 view.setOnClickListener() 分别实例化单击侦听器并将其注册到每个 ListView 项视图。使用它_代替_您当前拥有的全局列表项单击侦听器。
  2. 自己修复错误:fork 项目,编辑 OverScrollBounceEffectDecoratorBase.java,跳转到第 #250 行并将返回值更改为 'true'。这将导致 'touch-up' 事件被过度滚动而不是转移到 ListView 本身。 当然,这意味着您必须在本地编译项目(例如,在 build.gradle 中使用 'compile project(':overscroll')' - 如果您需要帮助,请告诉我)。

我已经修复并推送了这个问题——将包含在下一个 lib 版本中。再次感谢!

Hello, author, has listview been repaired? I use the package of 1.11 and will still call onclick event