Android OnTouchEvent:调试InputEventConsistencyVerifier消息
我有一个配置了OnTouchEvent()
手势监听器的布局。 该布局包含一个列表视图,我正在使用手势来捕获列表视图的行ID。 我有以下代码 -
itemsList.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent evt) {
// TODO Auto-generated method stub
//
int action = evt.getAction();
final String DEBUG_TAG = "DEBUG";
detector.onTouchEvent(evt);
switch(action) {
case (MotionEvent.ACTION_DOWN) :
Log.d(DEBUG_TAG,"Action was DOWN");
return true;
case (MotionEvent.ACTION_MOVE) :
Log.d(DEBUG_TAG,"Action was MOVE");
return true;
case (MotionEvent.ACTION_UP) :
Log.d(DEBUG_TAG,"Action was UP");
return true;
case (MotionEvent.ACTION_CANCEL) :
Log.d(DEBUG_TAG,"Action was CANCEL");
return true;
case (MotionEvent.ACTION_OUTSIDE) :
Log.d(DEBUG_TAG,"Movement occurred outside bounds " +
"of current screen element");
return true;
}
return false;
}
});
检测器是GestureDetector实例。 我基本上只使用向左滑动或在列表视图的一行上滑动右侧操作。
每当我向左/向右滑动,我都会在Logcat中收到3条调试消息(信息或要查看的东西??)。
D/InputEventConsistencyVerifier(24700): TouchEvent: ACTION_MOVE contained 1 pointers
but there are currently 0 pointers down.
D/InputEventConsistencyVerifier(24700): in android.view.GestureDetector@b50cf9b0
D/InputEventConsistencyVerifier(23596): 0: sent at 37751425150760,
MotionEvent { action=ACTION_MOVE, id[0]=0, x[0]=39.00721, y[0]=28.526703, toolType[0]=TOOL_TYPE_FINGER,
buttonState=0, metaState=0, flags=0x0, edgeFlags=0x0, pointerCount=1, historySize=1, eventTime=37751425,
downTime=37751133, deviceId=0, source=0x1002 }
OnTouchListener中还有4条调试消息 -
Action was ACTION MOVE
Action was ACTION MOVE
Action was ACTION MOVE
Action was ACTION UP
这相当于我相信的滑动运动。
主要活动类扩展了OnGestureListener
因此有其未实现的方法,如onFling等等。
问题是只有在ACTION UP
事件之后调用onFling方法,并且发生这种情况时,传递给方法mevt1的参数为null,而mevt2不为null。 (默认行为?)
onFling(MotionEvent mevt1,MotionEvent mevt2,float velX,float velY)
该方法使用mevt1,因此这会导致nullpointexception。
我想知道来自InputEventConsistencyVerifier
的调试消息是否有任何问题,并且如果有人知道这是否有任何问题?
你必须打电话
detector.onTouchEvent(evt)
对于每个动作,不只是ACTION_MOVE
链接地址: http://www.djcxy.com/p/91229.html上一篇: Android OnTouchEvent: Debugging InputEventConsistencyVerifier messages