-4

I want use countDown timer in my application and i should create such as this : Click too see image

How can i create countDownTimer such as above design?

user2314737
  • 27,088
  • 20
  • 102
  • 114
dfg
  • 27
  • 2
  • 3
  • Possible duplicate of [How to make a countdown Timer in android?](https://stackoverflow.com/questions/10032003/how-to-make-a-countdown-timer-in-android) – Abhishek Aryan Jun 03 '17 at 07:48

3 Answers3

2
private void downTimer(){
    new CountDownTimer(120*1000,1000) {
        @Override
        public void onTick(long millisUntilFinished) {
            long second = (millisUntilFinished / 1000) % 60;
            long minutes = (millisUntilFinished/(1000*60)) % 60;
            textViewCountDownTimer.setText(minutes + ":" + second);
        }

        @Override
        public void onFinish() {
            textViewCountDownTimer.setText("Finish");
        }
    }.start();
}
Meysam Keshvari
  • 1,141
  • 12
  • 14
1

Example of showing a 30 second countdown in a text field:

new CountDownTimer(30000, 1000) {

    public void onTick(long millisUntilFinished) {
         mTextField.setText("seconds remaining: " + millisUntilFinished / 1000);
    }

    public void onFinish() {
         mTextField.setText("done!");
    }

}.start();

Visit https://developer.android.com/reference/android/os/CountDownTimer.html

Rishabh Sharma
  • 270
  • 5
  • 17
  • please see my images in my post. i want create such as this – dfg Jun 03 '17 at 09:57
  • You need to make a custom layout for that. Like in above code there is mTextFied. Start with only displaying seconds then improvise your code according to the need. – Rishabh Sharma Jun 03 '17 at 10:14
1

Maybe this can help you :

https://github.com/tsuryo/Android-Countdown-Timer

    <com.tsuryo.androidcountdown.Counter
    android:id="@+id/counte1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:max_time_unit="DAY"
    app:text_color="#2196F3"
    app:text_size="36dp"
    app:textual_description="true"
    app:counter_font="DIGITAL_BOLD" />

and Java:

mCounter = findViewById(R.id.counter);
mCounter.setDate("2019-07-19T18:33:00"); //countdown starts
  • Hello bro, how about on a daily basis? for example the countdown will always start at 11:15AM and it will ends at 11:00AM on the following day? – Clinton Canarias Sep 08 '21 at 06:57