i have following code...
public boolean onTouch(View view, MotionEvent me) {
//here i want to know the time of touch
switch (me.getAction()) {
case MotionEvent.ACTION_DOWN: { }
case MotionEvent.ACTION_UP: { }
-
-
-
}
}
Any Idea?
It is pretty simple
public yourClass{
long down;
public boolean onTouch(View view, MotionEvent me) {
//you don't need here the difference because it might be a down action!
//you need the difference when the up action occurs
switch (me.getAction()) {
case MotionEvent.ACTION_DOWN:
down = System.currentTimeMillis();
break;
case MotionEvent.ACTION_UP:
//this is the time in milliseconds
long diff = System.currentTimeMillis() - down;
break;
}
}
}