【发布时间】:2015-01-30 10:19:46
【问题描述】:
我有列表视图。用户可以在覆盖此列表视图的全屏Window.FEATURE_NO_TITLE) 上打开对话框。当用户触摸此对话框的背景时,它会关闭。
我需要将此触摸事件委托给列表视图。我的意思是,在 bg 上的 MotionEvent.ACTION_DOWN 之后,我需要关闭对话框(它工作正常),然后在列表视图上启动 MotionEvent.ACTION_DOWN。
我尝试过这样的事情:
((LinearLayout) findViewById(R.id.dialog_bg)).setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
MotionEvent motionEvent = MotionEvent.obtain(event);
activity.findViewById(R.id.fr_projects_list).dispatchTouchEvent(motionEvent);
close();
break;
default:
break;
}
return false;
}
});
它在列表视图中以 ACTION_DOWN 开头。但仅此而已。 ACTION_MOVE 和其他不起作用 =/
【问题讨论】:
标签: android android-listview android-event