Android-PullToRefresh-SwipeMenuListView-Sample icon indicating copy to clipboard operation
Android-PullToRefresh-SwipeMenuListView-Sample copied to clipboard

list view do not trigger action down in ontouchevent

Open nightkidfifa opened this issue 8 years ago • 0 comments

move the code in switch case ACTION_DOWN and above in onTouchEvent to onInterceptTouchEvent , something like this ///////////////start/////////////////////////////////////////////// `@Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (mLastY == -1) { mLastY = ev.getRawY(); }

    switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:
            mLastY = ev.getRawY();

            int oldPos = mTouchPosition;
            mDownX = ev.getX();
            mDownY = ev.getY();
            mTouchState = TOUCH_STATE_NONE;

            mTouchPosition =
                    pointToPosition((int) ev.getX(), (int) ev.getY());

            if (mTouchPosition == oldPos && mTouchView != null &&
                    mTouchView.isOpen()) {
                mTouchState = TOUCH_STATE_X;
                mTouchView.onSwipe(ev);
                return true;
            }

            View view =
                    getChildAt(mTouchPosition - getFirstVisiblePosition());

            if (mTouchView != null && mTouchView.isOpen()) {
                mTouchView.smoothCloseMenu();
                mTouchView = null;
                return super.onTouchEvent(ev);
            }
            if (view instanceof SwipeMenuLayout) {
                mTouchView = (SwipeMenuLayout) view;
            }
            if (mTouchView != null) {
                mTouchView.onSwipe(ev);
            }
            break;
        default:
            break;
    }

    return super.onInterceptTouchEvent(ev);
}

@Override
public boolean onTouchEvent(MotionEvent ev) {

    switch (ev.getAction()) {
        case MotionEvent.ACTION_DOWN:

            break;
        case MotionEvent.ACTION_MOVE:
            final float deltaY = ev.getRawY() - mLastY;
           ……`

//////////////////////end/////////////////// http://www.evolvestar.com/want/android-listview-ontouchevent-doesn-give-action_down

nightkidfifa avatar Dec 23 '16 06:12 nightkidfifa