onTouchEvent和GestureListener

hongse114 2011-08-03 09:37:58
我的程序是这样的。
public boolean onTouchEvent(MotionEvent event) {

switch(event.getAction()){

case MotionEvent.ACTION_UP:
float x=event.getX();
float y=event.getY();
if(left(x,y)){
log.d("run","left---up");;
}
if(right(x, y)){
log.d("run","right---up");
}
Log.d("run", "upupupupu");
return false;
case MotionEvent.ACTION_DOWN:
Log.d("run", "down");
return myGestureDetector.onTouchEvent(event);
case MotionEvent.ACTION_MOVE:
Log.d("run", "move");
return myGestureDetector.onTouchEvent(event);
default:
break;
}
Log.d("run", "return");
return myGestureDetector.onTouchEvent(event);
}

类是这样的:
public class MyView extends SurfaceView implements Callback, OnGestureListener,Runnable

定义了一个手势识别的:
public GestureDetector myGestureDetector=null;

并new出了对象:
myGestureDetector=new GestureDetector(this);

问题是:只响应actionDown的处理,不响应actionUp。为什么呢?
...全文
259 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
mic47 2011-08-10
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 dinjay 的回复:]

case MotionEvent.ACTION_UP
这里你没有交给GestureDetector去处理啊
[/Quote]

ding.
hongse114 2011-08-03
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 dinjay 的回复:]

case MotionEvent.ACTION_UP
这里你没有交给GestureDetector去处理啊
[/Quote]

gestureDetector中的哪个函数来处理?

但我的case中有代码处理它啊?他怎么一句代码都没执行,而且好像就没有up这一项似的。
dinjay 2011-08-03
  • 打赏
  • 举报
回复
case MotionEvent.ACTION_UP
这里你没有交给GestureDetector去处理啊

80,492

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧