Posts

Showing posts with the label Stopwatch App

Create a Stopwatch App using Chronometer in Sketchware

Image
To create a Stopwatch App in sketchware using Chronometer, follow the steps given below. 1. Create a new project in Sketchware. 2. In VIEW area add a LinearV with width and height as match_parent, and gravity as center_horizontal, center_vertical. • Inside this add a LinearH linear2 with width 240, height 240, padding 20, magin 8, and gravity center_horizontal, center_vertical. • Below linear2, add two Buttons start_button and pause_button . Set their margins as 8 and text as START and PAUSE respectively. 3. Create a more block  extra . 4. In the more block  extra , use an  add source directly  blocks and put codes to declare a long variable timeWhenStopped, and a Chronometer stopclock. } private long timeWhenStopped = 0; private Chronometer stopclock; { 5. Add 5 number variables mode , ZERO , RUNNING , STOPPED , PAUSED . 6. In  onCreate  event, set ZERO to 0, RUNNING to 1, STOPPED to 2, PAUSED to 3, and mode to ZERO. After ...

Create Stopwatch App in Android using Sketchware

Image
Timer component and number variables can be used to add a Stopwatch to your Android App created in Sketchware. To create a Stopwatch App in Sketchware follow the steps below. 1. Start a new project in Sketchware . Fill app name, package name and app icon. 2. In VIEW area, insert a Textview and a Button  widget. In Textview properties set layout_gravity as center_horizontal, text as 00:00:00.00, and text_size as 40sp. In Button properties set layout_gravity as center_horizontal, text as Start/Stop/Reset and text_size as 20sp. 3. In LOGIC area add a new timer component t . 4. In onCreate event, add five number variables , one each for hour, minutes, seconds, and milliseconds, and an extra variable for managing Button Click. Set all these number variables to 0. 5. Suppose the five number variables are named as h , m , s , ms , and start . 6. Then in Button​ onClick event use if..then..else control as shown in the image below. This will change va...