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
152 views
in Technique[技术] by (71.8m points)

android - How to work, when listview inside the scrollview?

I doing this In Android 1.6 and 2.2 ...

I have One ScrollView in the Activity (All the content in the ScrollView) ...

And Second is, One ListView in the Activity ....

When I Scroll ListView, at that time ScrollView is scrolling but ListView's Scroll is not working ...

I provide the scatch of the problem which I have ...

If anyone have solution of this, then please share ...

enter image description here

See Question&Answers more detail:os

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

1 Reply

0 votes
by (71.8m points)

here parentScroll = your main scrollview and childScroll = your listview

parentScroll.setOnTouchListener(new View.OnTouchListener() {

                public boolean onTouch(View v, MotionEvent event) {
                    Log.v("PARENT", "PARENT TOUCH");
                    findViewById(R.id.child_scroll).getParent()
                            .requestDisallowInterceptTouchEvent(false);
                    return false;
                }
            });

  childScroll.setOnTouchListener(new View.OnTouchListener() {

                public boolean onTouch(View v, MotionEvent event) {
                    Log.v("CHILD", "CHILD TOUCH");
                    // Disallow the touch request for parent scroll on touch of
                    // child view
                    v.getParent().requestDisallowInterceptTouchEvent(true);
                    return false;
                }
            });

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

...