title: CountDownTimer in Kotlin explanation
body: <p>I am very very new to Kotlin and as well as Java.
  I have search around the web and found tutorials about using CountDownTimer in Kotlin but i still do not understand. I am trying to create an android app with a page that whenever you open it, it counts down for 60 sec to 0.</p>
  
  <p>Below is what I have done, Was trying to create a charade game.
  The problem is that there is an error on textTimer.text, (unresolved reference), i don't see where i am wrong though. And is my Timer correct? Is there a better and easier way to do it?</p>
  
  <p>I follow this tutorial. <a href="https://android--code.blogspot.com/2018/04/android-kotlin-countdowntimer-days.html" rel="nofollow noreferrer">https://android--code.blogspot.com/2018/04/android-kotlin-countdowntimer-days.html</a></p>
  
  <pre><code>package com.example.sim.charades
  import android.support.v7.app.AppCompatActivity
  import android.os.Bundle
  import android.os.CountDownTimer
  import android.widget.TextView
  import kotlinx.android.synthetic.main.activity_main.*
  import java.util.*
  import java.util.concurrent.TimeUnit
  
  class QuickStart : AppCompatActivity() {
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_quick_start)
  
          val textView = findViewById&lt;TextView&gt;(R.id.textView)
          val textTimer = findViewById&lt;TextView&gt;(R.id.textTimer)
          val arrayTerms = arrayListOf("Burger", "Pie", "Fries", "Donuts", "Chocolates", "Sweets")
  
          val rand = Random().nextInt(arrayTerms.count())
          textView.text = arrayTerms[rand]
  
          // 60 seconds (1 minute)
          val minute:Long = 60000
  
          // 1 day 2 hours 35 minutes 50 seconds
          val millisInFuture:Long = (minute * 1440) + (minute * 155) + (1000 * 50)
  
          // Count down interval 1 second
          val countDownInterval:Long = 1000
  
          timer(millisInFuture,countDownInterval).start()
  
  
      }
  
      private fun timer(millisInFuture:Long,countDownInterval:Long):CountDownTimer{
          return object: CountDownTimer(millisInFuture,countDownInterval){
              override fun onTick(millisUntilFinished: Long){
                  val timeRemaining = timeString(millisUntilFinished)
                  textTimer.text = timeRemaining
              }
  
              override fun onFinish() {
                  //nothing Yet
              }
          }
      }
  
      private fun timeString(millisUntilFinished:Long):String{
          var millisUntilFinished:Long = millisUntilFinished
  
          val seconds = TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished)
  
          // Format the string
          return String.format(
                  Locale.getDefault(),
                  "%02d sec",
                  seconds
          )
      }
  
  
  }
  </code></pre>
  
  <p>Thanks Guys</p>