问题描述
予有视频位于SD卡的列表。在这一点上,我只需要在列表视图中的每一行创建的手势或刷卡检测帮助。由于这个问题计算器机器人 - 基本手势检测,我实现了在列表视图的手势。现在,当用户扫描在正确的方向或向左方向很容易检测。但这种姿态是整个列表视图。我只是想知道我怎样才能实现这个刷卡检测单个行。例如,现在的应用程序,使一个打印右刷卡,左刷卡举杯。我只是想让它像右轻扫上排1号,左刷卡就行3号等。我希望我的问题是显而易见的。
I have a list of videos located in the sd-card. At this point, I just need help in creating gestures or swipe detection for each row in the list view. Thanks to this question at stackoverflow Android - basic gesture detection, I implemented the gesture on the listview. It now easily detects when the user swipes in the right direction or left direction. But this gesture is for the entire listview. I just want to know how can I implement this swipe detection for individual rows. For example, the application now makes a toast that prints "Right Swipe", "Left Swipe". I just want to make it like "Right Swipe on row no 1", "Left Swipe on Row no 3" etc.. I hope my question was clear.
期待一些有用的回复。谢谢
Looking forward to some helpful replies.Thanks
推荐答案
看看到这个答案并使用在 onFling
事件pointToPosition 方法
Take a look into this answer and use pointToPosition method inside onFling
Event
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
try {
Toast.makeText( listAdapter.getItem( listView.pointToPosition(Math.round(e1.getX()), Math.round(e1.getY())).toString());
return super.onFling();
} catch( Exception e ) {
// do nothing
}
}
这篇关于刷卡检测列表视图中的每一行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!