私有子类/手势检测器中的 Android 调试日志记录
我有一个简单的手势检测器,根据本教程,它在我的视图 onTouchEvent() 方法中传递所有 MotionEvent:
http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html
我的代码示例,它画了一个圆圈当手指触摸屏幕时:
@Override
public boolean onTouchEvent(MotionEvent ev) {
// send the touch event to the gesture detector
if (mBuildupDetector.onTouchEvent(ev)) {
Log.d(LOG_TAG, "onTouchEvent(): Gesture consumed.");
} else {
Log.d(LOG_TAG, "onTouchEvent(): Gesture not consumed.");
}
switch (curAction) {
case MotionEvent.ACTION_DOWN: {
drawCircle();
}
}
}
然后是手势检测器的私有子类:
private class BuildupListener extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onDown(MotionEvent ev) {
Log.d("BuildupListener", "onDown(): Triggered.");
return true;
}
}
因此,当用户触摸屏幕并生成运动事件时,我得到一个确认,即该手势确实被“消耗”了,并且我可以在GestureDetector的onDown方法中改变圆的直径。但是,即使 onDown 看起来被调用并执行,也不会写出任何日志记录。
我是否缺少有关日志记录的基本信息以及如何从私有子类或手势检测器内部进行日志记录?
谢谢,
保罗
I have a simple Gesture Detector that is passed all MotionEvents in my Views onTouchEvent() method, per this tutorial:
http://android-developers.blogspot.com/2010/06/making-sense-of-multitouch.html
A sample of my code, which draws a circle around the finger when it touches the screen:
@Override
public boolean onTouchEvent(MotionEvent ev) {
// send the touch event to the gesture detector
if (mBuildupDetector.onTouchEvent(ev)) {
Log.d(LOG_TAG, "onTouchEvent(): Gesture consumed.");
} else {
Log.d(LOG_TAG, "onTouchEvent(): Gesture not consumed.");
}
switch (curAction) {
case MotionEvent.ACTION_DOWN: {
drawCircle();
}
}
}
And then a private sub-class for the gesture detector:
private class BuildupListener extends GestureDetector.SimpleOnGestureListener {
@Override
public boolean onDown(MotionEvent ev) {
Log.d("BuildupListener", "onDown(): Triggered.");
return true;
}
}
So, when the user touches the screen, generating a motion event, I am getting a confimation that the gesture was indeed 'consumed', and I can change the diameter of the circle in the onDown method of the GestureDectector. However, no logging is written out from onDown, even though it appears to be called and executed.
Am I missing something basic about logging and how logging can happen from inside private sub-classes, or gesture detectors?
Thanks,
Paul
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
发现问题了,我相信这是 LogCat 的错误。从 Eclipse 中删除 LogCat 选项卡并重新启用它会导致所有日志记录按预期显示。
Found the issue, it was an error with LogCat I believe. Dropping the LogCat tab from Eclipse and re-enabling it resulted in all the logging being shown as expected.