I want to develop a simple stop watch logic in android.
On clicking a list view the timer should start and on clicking the button the timer should stop. Can anyone please guide me. Any sample code will be of great help
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use the Stopwatch Class (For higher precision use
System.nanoTime())Add a Start() event and Stop() event on Button Presses. You’ll need to update the UI so use a Thread/Handler Combination.
This should get you started.
EDIT: Added Code. (Nice Exercise! 🙂 )
Use the
Refresh_Rateto configure how often your UI is updated.