package com.joyplus.widget; import android.content.Context; import android.util.AttributeSet; import android.view.MotionEvent; import android.widget.ListView; import android.widget.ScrollView; public class InnerListView extends ListView { ScrollView parentScrollView; public ScrollView getParentScrollView() { return parentScrollView; } public void setParentScrollView(ScrollView parentScrollView) { this.parentScrollView = parentScrollView; } private int maxHeight; public int getMaxHeight() { return maxHeight; } public void setMaxHeight(int maxHeight) { this.maxHeight = maxHeight; } public InnerListView(Context context, AttributeSet attrs) { super(context, attrs); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // TODO Auto-generated method stub if (maxHeight > -1) { heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); System.out.println(getChildAt(0)); } @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { // TODO Auto-generated method stub super.onSizeChanged(w, h, oldw, oldh); this.setFocusable(false); } @Override public boolean onInterceptTouchEvent(MotionEvent ev) { switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: setParentScrollAble(false); case MotionEvent.ACTION_MOVE: break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: setParentScrollAble(true); break; default: break; } return super.onInterceptTouchEvent(ev); } /** * @param flag */ private void setParentScrollAble(boolean flag) { parentScrollView.requestDisallowInterceptTouchEvent(!flag); } }