开发者

I want my tablerow sensitive to OnSwipe-touch in Android, but it is too sensitive to onClick

开发者 https://www.devze.com 2023-03-10 15:09 出处:网络
I want to开发者_如何学Python make my tableRow listen to OnSwipe, and then show a delete-button. I have added a gesturedetector and it shows the button when I swipe. But since I also have a onClick-lis

I want to开发者_如何学Python make my tableRow listen to OnSwipe, and then show a delete-button. I have added a gesturedetector and it shows the button when I swipe. But since I also have a onClick-listener, the onclick always fires and makes the user leave the activity.

I have tried to disable the OnClick-listener, but that didn't make a difference. I also want the button to stay visible even after the swipe, as it is now is goes away after the swipe is finished.

public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
    float velocityY) {
    try {
    if (Math.abs(e1.getY() - e2.getY()) > SWIPE_MAX_OFF_PATH)
    return false;
    // right to left swipe
    tr.setEnabled(false);
    btnDelete.setVisibility(View.VISIBLE);

    }

Thanks!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号