`
googlelee
  • 浏览: 114396 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Android 侦测手势的内部类

阅读更多
public class MyGesture implements GestureDetector.OnGestureListener
{
@Override
public boolean onDown(MotionEvent arg0) {
// TODO Auto-generated method stub
bt6.setText("onDown");
return false;
}

@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float arg2,
float arg3) {
// TODO Auto-generated method stub
bt6.setText("onFling");
/*
if (e1.getX() > e2.getX()) {// move to left
vf1.showNext();
} else if (e1.getX() < e2.getX()) {
vf1.setInAnimation(getApplicationContext(),
R.anim.push_right_in);
vf1.setOutAnimation(getApplicationContext(),
R.anim.push_right_out);
vf1.showPrevious();
vf1.setInAnimation(getApplicationContext(),
R.anim.push_left_in);
vf1.setOutAnimation(getApplicationContext(),
R.anim.push_left_out);
} else {
return false;
}
*/
return true;
}

@Override
public void onLongPress(MotionEvent arg0) {
// TODO Auto-generated method stub

}

@Override
public boolean onScroll(MotionEvent arg0, MotionEvent arg1, float arg2,
float arg3) {
// TODO Auto-generated method stub
bt6.setText("onScroll");
return false;
}

@Override
public void onShowPress(MotionEvent arg0) {
// TODO Auto-generated method stub

}

@Override
public boolean onSingleTapUp(MotionEvent arg0) {
// TODO Auto-generated method stub
return false;
}
}//myges class

重写以下方法,将点击以后的事件传给该类的对象。
@Override
public boolean onTouchEvent(MotionEvent arg1) {
// TODO Auto-generated method stub
return gd1.onTouchEvent(arg1);
//return true;
}

@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
// TODO Auto-generated method stub
return gd1.onTouchEvent(arg1);
//return false;
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics