Android 获取手势onfling代码片段

public class AutoFile extends Activity implements OnTouchListener{

private GestureDetector gd1;
private MyGesture mg1;
private ViewFlipper vf1 =null;

        mg1 = new MyGesture();
        gd1 = new GestureDetector(AutoFile.this,mg1);

        tv2.setOnTouchListener(this);
        tv2.setLongClickable(true);

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 arg0, MotionEvent arg1, float arg2,
float arg3) {
// TODO Auto-generated method stub
bt6.setText("onFling");
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 onTouch(View arg0, MotionEvent arg1) {
// TODO Auto-generated method stub
return gd1.onTouchEvent(arg1);
//return true;
}

你可能感兴趣的:(android)