Scrolling with Multiple ListViews for Android

Forward touch event from touched view to other views. All your views will be synchronized expand/collapsed too.

OnTouchListener mOnTouch = new OnTouchListener() {

    @Override
    public boolean onTouch(View v, MotionEvent event) {            
        MotionEvent newEvent = MotionEvent.obtain(event);

        switch(event.getAction()) {  
            case MotionEvent.ACTION_MOVE:
                if(mTouched == null) {
                    mTouched = v;
                }
                mMovingFlag = true;
                break;
            case MotionEvent.ACTION_UP:
                if(mMovingFlag==false) {
                    newEvent.setAction(MotionEvent.ACTION_CANCEL);
                }
                mMovingFlag = false;
                break;
            default:
                mMovingFlag = false;
                if(mTouched != null && mTouched.equals(v)) {
                    mTouched = null;
                }
                break;
        }

        if(mTouched == null || mTouched.equals(v)) {
            int items = mLayoutWithListViews.getChildCount();
            for(int i = 0; i < items; i++) {
                AbsListView listView = mLayoutWithListViews.getChildAt(i));
                if(listView != v) {
                    listView.onTouchEvent(newEvent);
                }
            }
        }

        return false;
    }
};

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)