title: How to use dataBinding with spinner and get the current value?
body: <p>I am developing an android app using MVVM and data binding ( Kotlin ), I want to know how to easily get the current value of the spinner in my ViewModel and handle it easily.
  I know this question was asked s many times but actually I didn't get my useful answer, So can you help guys??
  Appreciate your help.
  Thanks. </p>
  
  <pre><code>
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;layout 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"&gt;
  
      &lt;data&gt;
  
          &lt;variable
              name="registerviewmodel"
              type="com.AAA.BBB.SignUpAuthViewModel" /&gt;
      &lt;/data&gt;
  &lt;Spinner
                  android:id="@+id/citySpinnerSignUpLayout"
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:layout_margin="15dp"
                  android:entries="@array/cities"
                  /&gt;
  
      &lt;/ScrollView&gt;
  &lt;/layout&gt;
  </code></pre>
  
  <pre><code>class SignUpAuthViewModel : ViewModel() {
  
      var username: String? = null
      var password: String? = null
      var town: String? = null
      var age: String? = null
      var phone: String? = null
      var passwordConfirmation: String? = null
  
  
  
  //this variable should hold the city of the user
  // from spinner of cities
  var cityOfUser: String? = null
  
  
  
      fun OnRegisterButtonClicked(view: View) {
      }
  
      fun onRegisterTextViewClicked(view: View) {
      }
  }
  
  </code></pre>