How can I get my ListView to scroll?

后端 未结 4 930
梦谈多话
梦谈多话 2020-12-09 05:32

I have a quite complex View build-up, and as a part of that, I have a ListView inside a LinearLayout within a ScrollView (and quite a lot more components, but they do not ma

4条回答
  •  自闭症患者
    2020-12-09 05:49

    Try this code may help you

            ListView listView = ( ListView ) findViewById(R.id.lsvButton3);
            listView.setOnTouchListener(new ListView.OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    int action = event.getAction();
                    switch (action) {
                        case MotionEvent.ACTION_DOWN:
                            // Disallow ScrollView to intercept touch events.
                            v.getParent().requestDisallowInterceptTouchEvent(true);
                            break;
    
                        case MotionEvent.ACTION_UP:
                            // Allow ScrollView to intercept touch events.
                            v.getParent().requestDisallowInterceptTouchEvent(false);
                            break;
                    }
    
                    // Handle ListView touch events.
                    v.onTouchEvent(event);
                    return true;
                }
            });
    

提交回复
热议问题