swiping items on listview, with small vertical margin

╄→гoц情女王★ 提交于 2019-12-10 11:45:07

问题


So I have a ListView on which I attach :

mList.setOnTouchListener(gestureListener);

What this gesture listener does is basically measure deltaX (horizontal swipe) and detects if it is higher than some value, then it knows that swipe has occured.

Then I have :

mList.setOnItemClickListener(new AdapterView.OnItemClickListener() { ... } 

Which checks with gesture object if swipe has happened, if yes its a swipe, otherwise its a click.

All this works fine.

My issue is :

When I swipe elements with my thumb, sometimes I make a list scroll just a bit vertically. The horizontal swipe is detected, but the problem is that OnItemClickListener doesnt fire, which is where I would launch some actions on the item depending if it is a swipe or not.

So the problem is that the vertical scroll mechanism of listview, makes something that makes onItemClicked event not to fire.

the list on the left works fine, no vertical scrolling appears. the list on the right, I swipe the item but slightly to the bottom as well (still within the bounds of this item) so that the list moves just a bit. And the OnItemClicked does not fire.

How can I add a small margin for vertical scroll, so that the scroll appears but the onItemClicked is still fired?

Thanks


回答1:


I was looking for implementation of swiping a listview, now when in December edition of Gmail there is a swiping effect on each item, its implementation answers my question

It can be found here :

https://gist.github.com/2980593



来源:https://stackoverflow.com/questions/12912061/swiping-items-on-listview-with-small-vertical-margin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!