刷卡上的列表视图项目,以小垂直边距 [英] swiping items on listview, with small vertical margin

查看:115
本文介绍了刷卡上的列表视图项目,以小垂直边距的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一个的ListView 上,我附上:

So I have a ListView on which I attach :

mList.setOnTouchListener(gestureListener);

这是什么姿态监听器基本上是衡量DELTAX(水平刷卡),并检测它是否比一些价值更高,则知道刷卡已发生。

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.

然后我有:

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

哪个手势对象,检查是否刷卡已经发生了,如果是它刷卡,否则其点击。

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

这一切工作正常。

我的问题是:

当我刷卡有我的拇指元素,有时我做一个列表中滚动只是有点垂直。
水平轻扫被检测到,但问题是, OnItemClickListener 犯规火,这是在那里我会发动取决于它是否是刷卡还是没有该项目的一些行动。

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.

所以,问题是,列表视图的垂直滚动机制,使得这是令onItemClicked事件不火。

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

在左侧的列表中工作正常,没有出现垂直滚动。
在右边的列表中,我刷卡的项目,但略微的底部以及(仍然在这个项目的边界),使该列表移动只是有点。和 OnItemClicked 不火。

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.

如何添加一个小幅度的垂直滚动,这样滚动出现,但onItemClicked还是开除了?

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

感谢

推荐答案

我一直在寻找实现刷卡列表视图中,
现在,当在Gmail年12月版有在每个项目上刷卡的效果,它的实施回答我的问题。

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

它可以在这里找到:

https://gist.github.com/2980593

这篇关于刷卡上的列表视图项目,以小垂直边距的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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