0
How would you make a countdown clock in android studio?
I have been trying to make an app and can not figure out how to make a simple countdown, any ideas?
11 Answers
+ 2
i can teach you how to do a countup , i think its the same :)
+ 1
I think this might help too - https://www.youtube.com/watch?v=7d6iKupzkEg&t=13s
+ 1
Wow, thank you so much, I will try to get this to run:)
+ 1
NP ! enjoy and if you need anything Im here :)
0
Yes if you could that would work :)
0
Name: Bar ID=XXXXXXXXX
****************************************************************
/////////////////////////////////MAIN ACTIVITY . JAVA ////////////////////////////////
*****************************************************************
package com.example.barpupco.counter;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import org.w3c.dom.Text;
public class MainActivity extends AppCompatActivity {
private int mCounter = 0;
Button btn;
TextView txv;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = (Button)findViewById(R.id.button2);
txv = (TextView)findViewById(R.id.textView);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
0
public void onClick(View v) {
mCounter ++;
txv.setText(Integer.toString(mCounter));
}
});
}
}
*************************************************************
////////////////////////////////////ACTIVITY MAIN////////////////////////////////
***********************************************************
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="532dp"
android:layout_marginTop="140dp"
android:orientation="vertical"
app:layout_constraintTop_toTopOf="parent"
app:layout_editor_a
0
app:layout_editor_absoluteX="8dp"
app:layout_editor_absoluteY="8dp"
tools:layout_editor_absoluteX="0dp">
<Button
android:id="@+id/button2"
android:layout_width="345dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="256dp"
android:layout_marginEnd="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="8dp"
android:text="CLICK ME"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
</LinearLayout>
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_heigh
0
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="256dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
android:text="0"
android:textSize="40sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
0
Hi Bar,
I managed to get the code to compile and run, although I did mean a countdown clock. I still needed a component that would count up as I am trying to make a push up app(just for learning purposes). Thank you very much 😊