android解决ScrollView嵌套ListView不能上拉加载

it2022-05-05  222

android解决ScrollView嵌套ListView不能上拉加载

P:scroll是你的scrollView 控件

只需要对你的scrollView 添加onTouchListener监听是否活动到底部 然后在进行接下来的操作

scroll.setOnTouchListener(new OnTouchListener() {                          @Override             public boolean onTouch(View v, MotionEvent event) {                 // TODO Auto-generated method stub                 switch(event.getAction()){                     case MotionEvent.ACTION_MOVE:{                         break;                     }                     case MotionEvent.ACTION_DOWN:{                         break;                     }                     case MotionEvent.ACTION_UP:{                         //当文本的measureheight 等于scroll滚动的长度+scroll的height                         if(scroll.getChildAt(0).getMeasuredHeight()<=scroll.getScrollY()+scroll.getHeight()){                           //TO DO这里是你接下来要做的操作

                        }else{                                                      }                         break;                     }                 }                 return false;             }         });     }

就是这么简单  复制到你的代码里面就好了


最新回复(0)