私有子类/手势检测器中的 Android 调试日志记录

发布于 2024-10-07 06:19:06 字数 1208 浏览 5 评论 0原文

我有一个简单的手势检测器,根据本教程,它在我的视图 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

农村范ル 2024-10-14 06:19:06

发现问题了,我相信这是 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文