Title | FA17-CSE-011 MAD Lab Terminal |
---|---|
Author | Taimoor Shan |
Course | electronic devices and circuits |
Institution | Mirpur University of Science and Technology |
Pages | 29 |
File Size | 759.5 KB |
File Type | |
Total Downloads | 64 |
Total Views | 132 |
This is brief introduction to device drivers...
Terminal Name: M. Taimoor Shan Roll No: FA17-CSE-011 Subject: Android App Development
Question No.2 Develop a Stopwatch App in Android Studio. It should have 3 features 1. Start 2. Stop 3. Reset Solution: Create a Stopwatch App using Android Studio The layout for Stopwatch includes:
A TextView: showing how much time has passed
Three Buttons: 1. Start: To start the stopwatch 2. Stop: To stop the stopwatch 3. Reset: To reset the stopwatch to 00:00:00
Steps to create the Stopwatch:
Create a new project for Stopwatch App
Add String resources
Update the Stopwatch layout code
Update the code for activity
Below are the steps one by one in detail: 1. Create a new project for Stopwatch App
Create a new Android project for an application named “Stopwatch” with a company domain of “taimoorshan.org”, making the package name “org.taimoorshan.stopwatch”
Create a New project and select Empty Activity
Configure the project
The minimum SDK should be API 14 so it can run on almost all devices.
An empty activity called “StopwatchActivity” and a layout called “activity_stopwatch” will be created.
2. Add String resources We are going to use three String values in our stopwatch layout, one for the text value of each button. These values are String resources, so they need to be added to strings.xml. Add the String values below to your version of strings.xml: Srtings.xml
GFG|Stopwatch Start Stop Reset
3. Update the Stopwatch layout code
Here is the XML for the layout. It describes a single text view that s used to display the
timer, and three buttons to control the stopwatch. Replace the XML currently in activity_stopwatch.xml with the XML shown here:
activity_stopwatch.xml...