简体   繁体   中英

OnTouchEvent reacts multiple while touching the screen

I've got the problem, that the onTouchEvent reacts to staying with the finger on screen and move the finger. That isn`t my aim. I want, that the OnTouchEvent only reacts if i tap on the screen, after this the OnTouchEvent should reactivate itself and the user have to click another time.

Anyone can solve my problem? I mean it's a little bit tricky with my timer, because i never leave the method OnTouchEvent.

public boolean onTouchEvent(MotionEvent me){
    if(!started){
        started = true;
        taptostart.setVisibility(View.GONE);
        expla.setVisibility(View.GONE);
        //start the timer
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                handler.post(new Runnable() {
                    @Override
                    public void run() {
                        changePos();
                    }
                });
            }
        }, 0, 20);
    }else{
        activateHo();
    }
    return false;
}
public boolean onTouchEvent(MotionEvent me){
    if(me.getAction() == MotionEvent.ACTION_DOWN){
       //Do what you want here, when the view is touched
    }
return false;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM