pressed

Android. How do I keep a button displayed as PRESSED until the action created by that button is finished?

删除回忆录丶 提交于 2019-11-26 18:29:24
问题 I have button_focused , button_pressed , and button_normal images. When I press the button, the button_pressed image is displayed and the action related to the button pressing begins. When I quit pressing the button, the action continues but the button returns to button_normal image being displayed. How can I set the button image being displayed to button_pressed during the entire action then reset to the button_normal image? Thank you for your time 回答1: I used a function like void

How to detect when button pressed and released on android

南笙酒味 提交于 2019-11-26 14:19:36
问题 I would like to start a timer that begins when a button is first pressed and ends when it is released (basically I want to measure how long a button is held down). I'll be using the System.nanoTime() method at both of those times, then subtract the initial number from the final one to get a measurement for the time elapsed while the button was held down. (If you have any suggestions for using something other than nanoTime() or some other way of measuring how long a button is held down, I'm