我有一个View
应该处理触摸的容器。它具有Listview
with overrided onTouch()
,它返回false
(true
当容器通过滑动展开时它将返回)。当Listview
触摸发生时,它传递到容器View
并且一切正常。但我需要为Listview
.
当我onClickListener
为项目设置时,我在日志中看到它没有MotionEvent
传递给容器,它被卡在了ListView
onTouch()
(返回false
并且什么都不做)。我正在尝试onTouchListener
为这样的项目设置:
viewHolder.itemLayout.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
return true;
case MotionEvent.ACTION_MOVE:
return false;
case MotionEvent.ACTION_UP:
Log.d(TAG, "something like click detected");
return true;
}
return false;
}
});
但结果是一样的。有人可以解释为什么我的容器没有收到触摸事件甚至ListView
返回false
它的覆盖onTouch()
吗?