我有以下OnTouchListener
I have the following OnTouchListener
gridview.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
if (event.getAction() == MotionEvent.ACTION_DOWN) {
start_x = event.getX();
start_y = event.getY();
Log.d(TAG,start_x + " " + start_y);
}
但体内的如果永远不会执行的语句。但是,对于其他活动,如ACTION_MOVE,相应的'如果'语句的身体并得到执行。任何人都知道为什么吗?
But the body of the 'if' statement is never executed. However, for other events, like ACTION_MOVE, the body of the corresponding 'if' statement does get executed. Anyone know why?
这可能是向下事件正被另一个观点消耗。尝试在活动超载onTouchEvent(MotionEvent),看看你能赶上活动。
It could be that the DOWN event is being consumed by another view. Try overloading "onTouchEvent(MotionEvent)" in your activity, and see if you are able to catch the event.