Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 312
Darshak Avatar asked Feb 25 '13 07:02

Darshak


1 Answers

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;
                }
            });
like image 89
kyogs Avatar answered Oct 15 '22 18:10

kyogs