Siten
Siten

Reputation: 4533

how can i show elapsed time in text view from 1h 30min

i m creating an online examination app.

this app require to show elapsed time from 1h 30min.

what should i take timer or what?

elapsetime = (TextView)findViewById(R.id.txtElapsedTime);
    elapsetime.setText(" "+hour+" h "+min+" m");

any suggestions?

Upvotes: 0

Views: 1140

Answers (2)

ashish.n
ashish.n

Reputation: 1224

Use this : Example of showing a 30 second countdown

new CountDownTimer(30000, 1000) {

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

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

stop the Counter we use the countDownTimer.cancel()

if you want to Pause and Resume the timer refer below link

http://example.javamonday.com/Open-Source/Android/Timer/multitimer-android/com/cycleindex/multitimer/CountDownTimerWithPause.java.htm

Refference : http://developer.android.com/reference/android/os/CountDownTimer.html

Upvotes: 1

Wroclai
Wroclai

Reputation: 26925

Use CountDownTimer.

Upvotes: 3

Related Questions