1

我正在一个Android应用程序中工作Titanium。我的问题是如何在 Titanium 中实现长触摸?我需要这样的东西:当用户按住某个视图来调用某个函数时。我试过这个:

arrowright.addEventListener('touchstart', function(e) {
        touched = true;
        setTimeout(function() {
            if (touched) {
                arrowright.fireEvent('longTouch');
            }
        },100);
    });

arrowright.addEventListener('touchmove', function(e) {
    touched = false;
});

arrowright.addEventListener('touchend', function(e) {
    touched = false;
});

arrowright.addEventListener('longTouch',function(){
                          clickTheView(e);
                         },
                         false);

但这不像我想要的那样工作。每次单击视图时都会调用我的函数 clickTheView(e) ,当我长时间触摸视图时不会调用它。

欢迎任何想法。提前致谢。

4

1 回答 1

0

如果您有最新的 Ti SDK,它包括在内。请参阅http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.Button.longpress-event.html

于 2012-03-16T14:58:25.610 回答