我有一个包含多个按钮的项目的列表视图。一项的布局如下所示:
我有一个覆盖的透明视图,覆盖了整个列表项。此视图监听两个手势:onDoubleTap
和onSingleTapConfimred
。
要触发底层按钮上的点击侦听器,我可以从覆盖的触摸侦听器中分派触摸事件,但这不会显示按钮上的选择器和状态(例如,按下时更改了背景颜色)。我也只想要在覆盖视图触发时触发点击事件onSingleTapConfimred
...
final DtGestureDetector detector = new DtGestureDetector(position);
final GestureDetector gd = new GestureDetector(convertView.getContext(), detector);
postViewHolder.viewOverlay.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
//i want to trigger this only onSingleTapConfirmed and set the view selector on touch
//postViewHolder.txtMessage.onTouchEvent(event);
//postViewHolder.layPhoto.onTouchEvent(event);
gd.onTouchEvent(event);
return true;
}
});
...
private class DtGestureDetector extends GestureDetector.SimpleOnGestureListener {
private int position;
public DtGestureDetector(int position) {
super();
this.position = position;
}
public boolean onDoubleTap(MotionEvent e) {
Log.d(tag, "DoubleTap"+position);
return true;
}
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
Log.d(tag, "SingleTap"+position);
return true;
}
}