简体   繁体   中英

android swipe gesture functions

can anyone tell me how to add functions in swipe gesture? eg onSwipeRight(), i don't want make a toast instead calculate from one to ten how much the screen was swiped and then store that data in some variable? like the samsung galaxy s5 image editor does while changing the brightness of the image

imageView.setOnTouchListener(new OnSwipeTouchListener() {

    public void onSwipeRight() {
        Toast.makeText(MyActivity.this, "right", Toast.LENGTH_SHORT).show();
    }

    public void onSwipeLeft() {
        Toast.makeText(MyActivity.this, "left", Toast.LENGTH_SHORT).show();
    }


    public boolean onTouch(View v, MotionEvent event) {
        return gestureDetector.onTouchEvent(event);
    }
});

使用GestureDetector检测onFling或仅使用https://stackoverflow.com/a/19506010/4651112的 OnSwipeTouchListener

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM