How To Make Header Of Listview Not To Consume The Touch Event
What I want I want the header of listView not to consume the touch event Problem I have a FrameLayout.In it, there are a mapview and a listview. The listview has a transparent head
Solution 1:
I try a lot of solutions in SO, but they are not work.Finally, I override the dispatchTouchEvent() function, it works.Complete version is over gist
,and key code is in here.
@OverridepublicbooleandispatchTouchEvent(MotionEvent motionEvent) {
if(mHeaderView == null) returnsuper.dispatchTouchEvent(motionEvent);
if(motionEvent.getAction() == MotionEvent.ACTION_DOWN){
//if touch header not to consume the eventRectrect=newRect((int) mHeaderView.getX(), (int) mHeaderView.getY(), mHeaderView.getRight(), mHeaderView.getBottom());
if(rect.contains((int)motionEvent.getX(), (int)motionEvent.getY())){
isDownEventConsumed = false;
return isDownEventConsumed;
}else {
isDownEventConsumed = true;
returnsuper.dispatchTouchEvent(motionEvent);
}
}else{
//if touch event not consumed, then move/up event should be the sameif(!isDownEventConsumed)return isDownEventConsumed;
returnsuper.dispatchTouchEvent(motionEvent);
}
}
Solution 2:
Did you try to set onClickListener null while inflate header view or this?
Post a Comment for "How To Make Header Of Listview Not To Consume The Touch Event"