English 中文(简体)
具体的双双踢
原标题:Specific Double Tap
  • 时间:2012-05-24 14:36:02
  •  标签:
  • android

我有可缩放图像,我使用 SqualGesture探测器。Splo onSqualGesture listener 。 我需要执行以下项目:

  1. On Single Tap appear Toast with information about picture.
  2. On Double Tap image is zooming.

我有一些问题。在双塔之前,单塔总是单塔,图片是放大的,但看起来是吐司。有什么办法可以避免单塔?我没有足够的智慧解决这个问题。

P.S. I I 不能使用 OnDoubleTapListener ,因为使用 SqualGesture探测器。SproceOnSqualGestureListener

<强 > UPD

case MotionEvent.ACTION_UP:
    firstTime = System.currentTimeMillis();
    if (Math.abs(firstTime-secondTime) < 300L) {
    // scale my matrix
    ---//---
    DONE = true; //this flag symbolize, that toast doesn t appear (false - appears)
    }
    else if (!DONE) {
         // making toast
    }
    secondTime = firstTime;
    break;

当双塔普启用图像缩放但显示土司时

最佳回答

@matt5784, 谢谢。我解决了我的问题。

case MotionEvent.ACTION_UP:
    float xDiff =  Math.abs(curr.x - start.x);
    float yDiff =  Math.abs(curr.y - start.y);
    firstTime = System.currentTimeMillis();
    if (Math.abs(firstTime-secondTime) > 200L) {
        myHand.postDelayed(mRun, 200);
    }
    else if (!DONE) {
        //scale my matrix
        DONE = true; //this flag symbolize, that toast doesn t appear (false - appears)
    }
    secondTime = firstTime;
    break;

Handler myHand = new Handler();
private Runnable mRun = new Runnable() {
    @Override
    public void run() {
        if (!DONE) {
                     // make toast
        }
    } 
问题回答

我建议实施延迟,如果信息不立即从一个水龙头上冒出,但只有在信息在合理的时间内(无论双声波的门槛值是多少)没有遇到第二个水龙头时才能显示出来。 也就是说,如果在2秒内设置信息,将任何水龙头登记为双声龙头,那么在等待2秒之前不要显示信息,并确保没有双声龙头。

替代解决方案( 可能不太有用 ) - - 使用双击/ zoom 函数调用使信息框消失的函数。 但是, 它可能会在很短的时间内弹出, 可能会显得愚蠢/ 有问题 。





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...