title: show data onClick data binding in Android
body: <p>I have the standard login form which has 2 edit text (one for email and other for password) and a button for log-in. </p>
  
  <p>I want to send email and password to the server when the user clicks on login button. </p>
  
  <p>activity_main.xml</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 class="ActivityMainBinding"&gt;
          &lt;variable
              name="login"
              type="com.example.itstym.reminder.loginViewModel" /&gt;
  
          &lt;variable
              name="handler"
              type="com.example.itstym.reminder.LoginHandler" /&gt;
      &lt;/data&gt;
  
  &lt;android.support.constraint.ConstraintLayout
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.example.itstym.reminder.MainActivity"&gt;
  
  
      &lt;EditText
          app:error="@{login.errorEmail}"
          android:text="@{login.userEmailAddress}"
          android:hint="Email Address"
          android:id="@+id/email_address"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_marginEnd="8dp"
          android:layout_marginStart="8dp"
          android:ems="10"
          android:inputType="textPersonName"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toStartOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          android:layout_marginTop="24dp"/&gt;
  
      &lt;EditText
          app:error="@{login.errorPassword}"
          android:text="@{login.userPassword}"
          android:hint="Password"
          android:id="@+id/user_password"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_marginEnd="8dp"
          android:layout_marginStart="0dp"
          android:ems="10"
          android:inputType="textPassword"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintStart_toStartOf="@+id/email_address"
          android:layout_marginTop="16dp"
          app:layout_constraintTop_toBottomOf="@+id/email_address"/&gt;
  
  
      &lt;Button
          android:onClick="@{() -&gt; handler.onLoginButtonClicked(login)}"
          android:id="@+id/submit_button"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_marginEnd="16dp"
          android:layout_marginStart="16dp"
          android:layout_marginTop="24dp"
          android:text="Sign In"
          app:layout_constraintEnd_toEndOf="@+id/user_password"
          app:layout_constraintStart_toStartOf="@+id/user_password"
          app:layout_constraintTop_toBottomOf="@+id/user_password"/&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  
  &lt;/layout&gt;
  </code></pre>
  
  <p>MainActivity.kt</p>
  
  <pre><code>class MainActivity : AppCompatActivity() {
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
  
          val binding=DataBindingUtil.setContentView&lt;com.example.itstym.reminder.databinding.ActivityMainBinding&gt;(this@MainActivity,R.layout.activity_main)
          Log.i("Binding class ",binding.javaClass.simpleName.toString())
          Log.i("type ",binding.javaClass.toString())
  
          val login:loginViewModel=loginViewModel()
  
          binding.login=login
  
          val handler= LoginHandler()
          binding.handler=handler
  
      }
  }
  </code></pre>
  
  <p>loginViewModel.kt</p>
  
  <pre><code>class loginViewModel(): BaseObservable() {
  
      @Bindable
      var userEmailAddress:String= String()
          set(userEmailAddress){
              field=userEmailAddress
              notifyPropertyChanged(R.id.email_address)
              /*to check Email for validation on every character inserted by user*/
              notifyPropertyChanged(BR.errorEmail)
  
          }
          get() {
          return field
      }
  
      @Bindable
      var userPassword:String = String()
          set(userPassword){
              field=userPassword
              notifyPropertyChanged(R.id.user_password)
              notifyPropertyChanged(BR.errorPassword)
          }
          get() {
              return field
          }
  
  }
  </code></pre>
  
  <p>//some code removed for readablitly purpose</p>
  
  <p>LoginHandler.kt</p>
  
  <pre><code>class LoginHandler() {
  
      fun onLoginButtonClicked(userInfo: loginViewModel){
  
          Log.i("Button Clicked ","yup")
          Log.i("Email is ",userInfo.userEmailAddress)
          Log.i("Password is ",userInfo.userPassword)
  
      }
  
  }
  </code></pre>
  
  <p><strong>Problem:</strong> I am not able to print the email address and password inside the written in onLoginButtonClicked(). Why?? </p>
  
  <p>Any lead will helpfull.</p>
  
  <p>Before downvoting the question, add the comment that will helps in improving the question. </p>