Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
361 views
in Technique[技术] by (71.8m points)

Scrolling with Multiple ListViews for Android

I'm completely stumped on this one. I have three different lists that need to be displayed on the screen. It's completely possible that the lists will extend past the bottom edge of the screen, so I would need scrolling.

I've tried using a ScrollView with a LinearLayout child, and putting my ListViews in the LinearView, but all of the ListViews lock to a fixed height with scroll bars. Using other kinds of Layouts means no scrolling.

Does anyone have any suggestions, or will I need to programmatically add the list items to some layout and hope for the best?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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 list=0; list<items; list++){
                    AbsListView listView =mLayoutWithListViews.getChildAt(list));
                    if(listView != v){
                         listView.onTouchEvent(newEvent);
                    }
                }
            }
            return false;
        }
    };

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...