title: How to access a button in included layout using data binding
body: <p>I am using databinding in my application but button is not working. where am i making mistake in this code. i tried many solution but no luck. but if make button in <strong>activity_login.xml</strong> then button click works. i think i am not able to pass the view model to the included view. 
  Here is my code </p>
  
  <p><strong>activity_login.xml</strong></p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;layout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          xmlns:bind="http://schemas.android.com/apk/res-auto"&gt;
  
      &lt;data&gt;
          &lt;variable
                  name ="loginViewModel"
                  type="com.innowi.checoutrestaurantdashboard.view.main.MainViewModel"/&gt;
      &lt;/data&gt;
  
      &lt;android.support.constraint.ConstraintLayout
  
              xmlns:app="http://schemas.android.com/apk/res-auto"
              android:id="@+id/login_constraint_layout"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:background="@drawable/login_background_burgerstack"
              android:isScrollContainer="false"
              android:paddingEnd="32dp"
              android:paddingStart="32dp"
              tools:context=".view.main.LoginActivity"&gt;
  
  
  
          &lt;include
                  android:id="@+id/login_layout"
                  layout="@layout/layout_login"
                  android:layout_width="0dp"
                  android:layout_height="0dp"
                  bind:loginViewModel="@{loginViewModel}"
                  app:layout_constraintBottom_toBottomOf="parent"
                  app:layout_constraintEnd_toEndOf="parent"
                  app:layout_constraintStart_toStartOf="parent"
                  app:layout_constraintTop_toTopOf="parent"/&gt;
  
      &lt;/android.support.constraint.ConstraintLayout&gt;
  &lt;/layout&gt;
  </code></pre>
  
  <p><strong>layout_login.xml</strong></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"&gt;
      &lt;data&gt;
          &lt;variable
                  name ="loginViewModel"
                  type="com.innowi.checoutrestaurantdashboard.view.main.MainViewModel"/&gt;
      &lt;/data&gt;
  
  &lt;android.support.constraint.ConstraintLayout
  
  
      style="@style/Login"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:isScrollContainer="false"
      android:padding="32dp"&gt;
  
      &lt;Button
          android:id="@+id/login_button"
          android:layout_width="0dp"
          android:layout_height="wrap_content"
          android:layout_marginTop="32dp"
          android:background="@drawable/button_login_drawable"
          android:enabled="false"
          android:gravity="center"
          android:paddingBottom="16dp"
          android:paddingTop="16dp"
          android:text="@string/button_sign_in"
          android:textColor="@color/colorWhite"
          android:textSize="24sp"
          android:onClick="@{loginViewModel::onLoginButtonClick}"
          app:layout_constraintLeft_toLeftOf="@+id/login_username"
          app:layout_constraintRight_toRightOf="@+id/login_username"
          app:layout_constraintTop_toBottomOf="@+id/login_password" /&gt;
  .
  .
  .
  .
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  &lt;/layout&gt;
  </code></pre>
  
  <p><strong>MainViewModel.kt</strong></p>
  
  <pre><code>class MainViewModel @Inject constructor(
      private val loginRepository: LoginRepository
  ) : BaseViewModel() {
  
  
       fun onLoginButtonClick(view : View){
  
          performLogin()
      }
         .
         .
         .
  }
  </code></pre>
  
  <p><strong>LoginActivity.kt</strong></p>
  
  <pre><code>class LoginActivity : AppBaseActivity() {
  
      private lateinit var loginViewBinding: ActivityLoginBinding
      private lateinit var viewModel: MainViewModel
      private val TAG = LoginActivity::class.simpleName
  
      override fun initViewModel(viewModelProvider: ViewModelProvider): BaseViewModel? {
          viewModel = viewModelProvider.get(MainViewModel::class.java)
          return viewModel
      }
  
      override fun render(state: ViewState) {
          when (state) {
              is LoadingState -&gt; {
                  // loading
                  val loading = state.loading
                  Log.d(TAG,"Loading State")
              }
              is DefaultState -&gt; {
                  // render Data
                  val data = state.data
                  Log.d(TAG,"Data State")
              }
              is ErrorState -&gt; {
                  // show error
                  val error = state.error
                  Log.d(TAG,"Loading State")
              }
          }
      }
  
      override fun setContentView() {
          loginViewBinding = DataBindingUtil.setContentView(this, R.layout.activity_login)
      }
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
  
          loginViewBinding.loginViewModel = viewModel
          loginViewBinding.executePendingBindings()
  
  
      }
  }
  </code></pre>