-1

I want to calculate duration of when Action_Down button before Action_Up in onTouchListener

Can I get how long my button was pressed? And doing something when timeout reaches to my desire value?

For example, i want to make a customize onLongClickListener with different timeout.

Edited

here and here and here is also like as this question but not is answer for this question. In these all used by Action_Up of onTouchListener that not are answer for this

Glorfindel
  • 21,988
  • 13
  • 81
  • 109

1 Answers1

0

You should override OnTouchEvent in your view, and if the event is ACTION_DOWN, record the current time by creating a new instance of Date. When you receive ACTION_UP or ACTION_CANCEL, create another instance of date and subtract the first value to get the difference in time.

fractalwrench
  • 4,028
  • 7
  • 33
  • 49
  • No buddy, you didn't read my question fully. I want calculate it before touch event equal to action_up –  Oct 12 '15 at 11:46
  • In that case you can post a delayed runnable when ACTION_DOWN is received, please clarify your question – fractalwrench Oct 12 '15 at 11:50