title: Android Kotlin pass value from textfields to numberPicker
body: <p>So I have these values (Long and Double) in three textfields. They represent time, pace, and distance.</p>
  
  <p>Now, to prevent user error I want to make them choose the values using numberPickers. I want to replace those textfields with those pickers.</p>
  
  <p>This is what I have:</p>
  
  <pre><code>val time = timeTxtField as TextView
      val distance = distanceTxtField as TextView
      val pace = paceTxtField as TextView
      var resetRunningBtn = clearBtn
      val pickerMinutes = numberPicker as NumberPicker
      val pickerSeconds = numberPickerSeconds as NumberPicker
  
      pickerMinutes.minValue = 0
      pickerMinutes.maxValue = 59
      pickerMinutes.wrapSelectorWheel = false
  
      pickerSeconds.minValue = 0
      pickerSeconds.maxValue = 60
      pickerSeconds.wrapSelectorWheel = false
  
  
  
  
      calculateBtn.setOnClickListener {
  
          when {
  
              time.text.isEmpty() &amp;&amp; (distance.text.isNotEmpty() &amp;&amp; pace.text.isNotEmpty()) -&gt;
                  calculatePace(null, distance.text.toString().toDouble(), pace.text.toString())
  
              distance.text.isEmpty() &amp;&amp; (time.text.isNotEmpty() &amp;&amp; pace.text.isNotEmpty()) -&gt;
                  calculatePace(time.text.toString(), null, pace.text.toString())
  
              pace.text.isEmpty() &amp;&amp; (time.text.isNotEmpty() &amp;&amp; distance.text.isNotEmpty()) -&gt;
                  calculatePace(time.text.toString(), distance.text.toString().toDouble(), null)
  
              else -&gt; {
                  Toast.makeText(this, "Please check fields",
                          Toast.LENGTH_SHORT).show()
              }
          }
      }
  </code></pre>
  
  <p>As you can see I have the pickers set and all that. I tried to call something like <code>.value</code> but it didn't work.</p>
  
  <p>This is my <a href="https://imgur.com/a/WP35Y" rel="nofollow noreferrer">layout</a>, so you can have a bit of understanding of the concept.</p>
  
  <p>Any tips? :)</p>
  
  <p>Thanks</p>
  
  <p><strong>EDIT XML:</strong></p>
  
  <pre><code>      &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;android.support.constraint.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="com.reecreate.woderator2.Controller.RunningCalculatorActivity"&gt;
  
  &lt;TextView
      android:id="@+id/textView5"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="8dp"
      android:text="Running Pace Calculator"
      android:textSize="24sp"
      android:textStyle="bold"
      android:inputType="numberDecimal"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toTopOf="parent" /&gt;
  
  &lt;EditText
      android:id="@+id/distanceTxtField"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="28dp"
      android:ems="10"
      android:hint="distance..."
      android:inputType="number|numberDecimal"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintHorizontal_bias="0.503"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toBottomOf="@+id/radioType" /&gt;
  
  &lt;EditText
      android:id="@+id/timeTxtField"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="16dp"
      android:ems="10"
      android:hint="time mm:ss"
      android:inputType="time"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toBottomOf="@+id/distanceTxtField" /&gt;
  
  &lt;EditText
      android:id="@+id/paceTxtField"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="16dp"
      android:ems="10"
      android:hint="pace mm:ss 10:21"
      android:inputType="time"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toBottomOf="@+id/timeTxtField" /&gt;
  
  &lt;RadioGroup
      android:id="@+id/radioType"
      android:layout_width="280dp"
      android:layout_height="56dp"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="24dp"
      android:orientation="horizontal"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toBottomOf="@+id/textView5"&gt;
  
      &lt;RadioButton
          android:id="@+id/milesDistanceRadioBtn"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginEnd="140dp"
          android:layout_marginTop="16dp"
          android:text="Miles"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintLeft_toRightOf="@id/kmDistanceRadioBtn"
          app:layout_constraintTop_toBottomOf="@id/textView5" /&gt;
  
      &lt;RadioButton
          android:id="@+id/kmDistanceRadioBtn"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginStart="8dp"
          android:layout_marginTop="16dp"
          android:text="KM"
          app:layout_constraintEnd_toStartOf="@+id/milesRadioBtn"
          app:layout_constraintHorizontal_bias="0.694"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent" /&gt;
  &lt;/RadioGroup&gt;
  
  &lt;RadioGroup
      android:id="@+id/paceRadioGroup"
      android:layout_width="wrap_content"
      android:layout_height="45dp"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="32dp"
      android:orientation="horizontal"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintHorizontal_bias="0.294"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toBottomOf="@+id/paceTxtField"&gt;
  
      &lt;RadioButton
          android:id="@+id/milesPaceRadioBtn"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginEnd="140dp"
          android:layout_marginTop="16dp"
          android:text="MILES PACE"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintLeft_toRightOf="@id/kmDistanceRadioBtn"
          app:layout_constraintTop_toTopOf="parent" /&gt;
  
      &lt;RadioButton
          android:id="@+id/kmPaceRadioBtn"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginStart="8dp"
          android:layout_marginTop="16dp"
          android:text="KM PACE"
          app:layout_constraintEnd_toStartOf="@+id/milesDistanceRadioBtn"
          app:layout_constraintHorizontal_bias="0.694"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent" /&gt;
  
  
  &lt;/RadioGroup&gt;
  
  
  &lt;Button
      android:id="@+id/calculateBtn"
      style="@style/Widget.AppCompat.Button.Borderless.Colored"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:background="@color/colorAccent"
      android:text="Calculate"
      android:textColor="@android:color/background_light"
      android:textStyle="bold"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent" /&gt;
  
  
  &lt;TextView
      android:id="@+id/result"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_marginEnd="24dp"
      android:layout_marginStart="24dp"
      android:layout_marginTop="24dp"
      android:background="@drawable/border"
      android:hint="Result"
      android:textAlignment="center"
      android:textSize="18sp"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintHorizontal_bias="0.0"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toBottomOf="@+id/paceRadioGroup" /&gt;
  
  &lt;Button
      android:id="@+id/clearBtn"
      style="@style/Widget.AppCompat.Button.Borderless"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:layout_marginTop="24dp"
      android:background="@color/colorAccent"
      android:text="CLEAR"
      android:textColor="@android:color/background_light"
      android:textStyle="bold"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toBottomOf="@+id/result" /&gt;
  &lt;NumberPicker
      android:id="@+id/numberPicker"
      android:layout_width="64dp"
      android:layout_height="119dp"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintHorizontal_bias="0.407"
      app:layout_constraintTop_toBottomOf="@+id/radioType" /&gt;
  
  &lt;NumberPicker
      android:id="@+id/numberPickerSeconds"
      android:layout_width="64dp"
      android:layout_height="119dp"
      android:layout_marginEnd="8dp"
      android:layout_marginTop="8dp"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintTop_toBottomOf="@+id/numberPicker" /&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>EDIT VALUE LISTENER</strong></p>
  
  <p>I added this, but not doing anything</p>
  
  <pre><code>var pickedValue: Int = pickerMinutes.value
      time.setText(Integer.toString(pickedValue))
  </code></pre>
  
  <p>................</p>
  
  <pre><code> when {
          pickerMinutes.isClickable -&gt; time.setText(Integer.toString(pickedValue))
  
      }
  
      numberPicker.setOnValueChangedListener { pickerMinutes, oldVal, newVal -&gt;
          //store values in variable for use later
      }
  </code></pre>