In my app, when one particular image button is clicked and held, i must be able to calculate the time for which the image button was held pressed. Can any one help me by giving some simple guidance or sample code. i am really stuck up here. Is there any specific event listener for this particular requirement. I am writing this app specifically for a touch screen phones only.
Share
What you want to use is this:
timeAtDown is a
longdefined as a class field, since it needs to persist between calls to the touchListener. Using this you don’t interfere with the button’s normal operation either; you can set a click listener which will function properly. Note: The ‘click’ operation doesn’t happen until the touch event’s action goes from DOWN (or MOVE) to UP.