Reputation: 4173
I'd like to perform an action when the user let his finger on a View more than 1 sec.
With OnTouch
, I can access to ACTION_UP
,ACTION_DOWN
and ACTION_MOVE
.
The problem is that if the user has his finger on the screen and doesn't move his finger, ACTION_MOVE
is not triggered and thus I can't perform my action.
I precise that I'd like to perform my action after 1sec but while the user still have its finger on screen.
In fact I'd need to sense that the user has his finger on the screen even if he's not moving it.
Thanks for your help.
Upvotes: 1
Views: 480
Reputation: 2854
Or you could use a longclickListener :)
View myView = findViewById(R.id.myView);
wv.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View v) {
//DO SOMETHING HERE
return true;
}
});
Upvotes: 1
Reputation: 785
You can Make Use of the TimerTask class and schedule a Task which will run after a specific time.
In case the user has lifted his finger before 1000 ms then just cancel the task scheduled upon ACTION_UP event.
Upvotes: 2