Kamis, 11 Mei 2023

Create Stopwatch App in Android using Sketchware

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 variable start to 1 on first Click, 2 on second click, and 0 on third click, thus making the button act as Start, stop and reset button respectively on the three clicks.

On third click when variable start changes from 2 to 0, set all other variables to 0, so that it acts as reset button.

7. In the starting if start=0, add a timer task for 10ms after every 10ms and use the blocks as given below:
If start=0 then
set start to 1
TimerTask t after 10ms for every 10ms
Number ms increase 1
If ms=100 then
set ms to 0
Number s increase 1
If s=60 then
set s to 0
Number m increase 1
If m=60 then
set m to 0
Number h increase 1
8. On Button Click, if start=1, set start to 2, and cancel timer task. If start=2, set start to 0, and set all other variables to 0.
9. Use join..and... operator, number variables, and ...to Decimal format... operator to set the text of textview as shown in the image below.
10. Use setText of textview inside timer task, and inside if start=2.
11. Save and run the project. The Stopwatch App is ready.
The video below shows the complete process:

Share:

1 komentar:

  1. Nice Blog.....thanks for this.... Just visit App in Minute can create Application and website without burden. App In Minute has the affordable Pricing and Making Plan by App In Minute of Rs. 5 / Day (Rs.1825/ Year.) It can be develop your free android application , website product and service to the world. for more information about how to create an app

    BalasHapus

Alam terbuka mengasyikkan di Destinasi impian

Jasa Pembuatan Website Archives - Legenda Web

loading...

Archive

Cari Blog Ini

Diberdayakan oleh Blogger.

Mengenai Saya

Foto saya
Saya memiliki Jasa Pembuatan Website Terpercaya
www.legendaweb.com

Pernah mengerjakan seo untuk Agen Travel door to door ecopremieretransindo.com dan Agen Travel Jakarta Jogja jakjogtrans.com

Juga memegang SEO Biro jasa paspor

Selain Itu, kerjasama dengan Sewa Mobil Bali Mai Bali Trans dan Industri pariwisata trip Bali dari beautrip.id

Labels

Admob ads in Sketchware Admob Ads in Sketchware App admob ads using AIDE Admob banner ads using AIDE Admob interstitial Ads Android app Android change status bar color animation in Sketchware background music Change color of checkbox in Sketchware change color of Seekbar change color of Switch button change status bar color code for moving image with finger in android code Injection create and share text file in Sketchware create text file in Sketchware Custom listview in android Custom ListView in Sketchware CustomView in Sketchware Dictionary Android App Dictionary Android project Dictionary App Dictionary App in Sketchware drag image enable download from Sketchware enable download in webview enable download without code Injection Enable image upload enable upload from webview enable upload from webview in android enable upload in Sketchware enable upload in webview​ using AIDE enable upload using AIDE gif image in Android App gif image in webview how to use ListView in Sketchware how to use Spinner image zoom Integrate Admob Ads in Sketchware Intent large paragraphs in Sketchware larger texts in Edittext. limit input text length load image in webview make image fit screen make scrollbar invisible media player move image with finger notification icon in Android notification in Android Notifications in Sketchware open other apps retrieve APK file retrieve source code share button share button in Android App share button in Sketchware App Share text file Sketchware sound on off sound play pause soundpool Soundpool for Multiple sounds Sounds in Android App stopwatch Android App Stopwatch App string list timer use of list