我的 SD 卡中有一个视频列表。此时,我只需要帮助为列表视图中的每一行创建手势或滑动检测。感谢 stackoverflow 上的这个问题网格布局上的滑动手势检测 https://stackoverflow.com/questions/937313/android-basic-gesture-detection,我在listview上实现了手势。现在,它可以轻松检测用户何时向右或向左滑动。但这个手势是针对整个列表视图的。我只是想知道如何对各个行实现这种滑动检测。例如,应用程序现在制作一个打印“向右滑动”、“向左滑动”的吐司。我只是想让它像“在第 1 行上向右滑动”、“在第 3 行上向左滑动”等。我希望我的问题很清楚。
期待一些有用的回复。
谢谢
看看这个答案 https://stackoverflow.com/a/1360693/1218268并使用点到位置 http://developer.android.com/reference/android/widget/AbsListView.html#pointToPosition%28int,%20int%29里面的方法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
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)