只需要重新listview即可
package com.exmple.listscrow; import java.util.logging.LogManager; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import android.view.View; import android.widget.ListView; public class MyListView extends ListView { int mLastMotionY; boolean bottomFlag; public MyListView(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // 对height重新赋值 heightMeasureSpec = MeasureSpec.makeMeasureSpec( /* Integer.MAX_VALUE>> 2 */300, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, heightMeasureSpec); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { if (bottomFlag) { getParent().requestDisallowInterceptTouchEvent(true); } return super.onInterceptTouchEvent(ev); } @Override public boolean onTouchEvent(MotionEvent ev) { int y = (int) ev.getRawY(); switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: // 妫f牕鍘涢幏锔藉焻down娴滃�娆�,鐠佹澘缍峺閸ф劖鐖� mLastMotionY = y; break; case MotionEvent.ACTION_MOVE: // deltaY > 0 閺勵垰鎮滄稉瀣�箥閸旓拷,< 0閺勵垰鎮滄稉濠呯箥閸旓拷 int deltaY = y - mLastMotionY; if (deltaY < 0) { View child = getChildAt(0); if (child != null) { if (getLastVisiblePosition() == (getChildCount() - 1) ) { bottomFlag = true; getParent().requestDisallowInterceptTouchEvent(true); } } } break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: break; } return super.onTouchEvent(ev); } }
注意:ScrollView只能有一个子类