水平滚动查看检测长preSS [英] Horizontal Scroll View detect long press
本文介绍了水平滚动查看检测长preSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有HSV,我想对这个观点很长的点击响应。当我设置它的 onLongClickListener()
它并没有做太多,回调不会被调用。
I have a HSV, and I'd like to respond to a long click on that view. When I set it's onLongClickListener()
it doesn't do much, the callback is not being called.
我假设滚动视图消耗与一切 onTouch
,以便它可以处理滚动,但我要如何解决呢?
I assume that the scroll view consumes everything with an onTouch
so it could handle the scrolling, but how do I work around it?
推荐答案
您可以用GestureDetector做到这一点。这工作:
You can do this with GestureDetector. This works:
GestureDetector.OnGestureListener listener = new GestureDetector.SimpleOnGestureListener() {
@Override
public void onLongPress(MotionEvent e)
{
Toast.makeText(TestXmlActivity.this, "LongClick", Toast.LENGTH_SHORT).show();
}
};
final GestureDetector gestureDetector = new GestureDetector(this, listener);
horizontalScrollView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event)
{
return gestureDetector.onTouchEvent(event);
}
});
这篇关于水平滚动查看检测长preSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文