Skip to content

Commit

Permalink
adding code link to article
Browse files Browse the repository at this point in the history
  • Loading branch information
droid-lover committed Aug 13, 2021
1 parent 2759e58 commit 32c6433
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion app/src/main/java/com/vs/chronometer/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ class MainActivity : AppCompatActivity() {
binding.chronometer.start()
}

fun stopTimer(){

fun stopTimer(view: View) {
binding.chronometer.stop()
Toast.makeText(this,"Timer stopped!",Toast.LENGTH_SHORT).show()
setupChronometer()
}

}
5 changes: 4 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:padding="16dp"
tools:context=".MainActivity">

Expand All @@ -17,6 +18,7 @@
android:layout_height="wrap_content"
android:layout_margin="28dp"
android:gravity="center"
android:textColor="@color/black"
android:textSize="18sp"
android:textStyle="normal"
app:layout_constraintEnd_toEndOf="parent"
Expand All @@ -29,6 +31,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/black"
android:foreground="?selectableItemBackgroundBorderless"
android:onClick="startTimer"
android:text="@string/start_timer"
android:textAllCaps="false"
Expand All @@ -39,12 +42,12 @@
app:layout_constraintStart_toStartOf="parent" />



<androidx.appcompat.widget.AppCompatButton
android:id="@+id/btnStopTimer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/black"
android:foreground="?selectableItemBackgroundBorderless"
android:onClick="stopTimer"
android:text="@string/stop_timer"
android:textAllCaps="false"
Expand Down

0 comments on commit 32c6433

Please sign in to comment.