title: OnClick buttons in the MVVM Fragment do not work
body: <p>I have a LoginActivity in which there are two fragments. Using the navigation library, I switch between these fragments. But now I need to go from the fragment to another Activity. My code doesn't work for some reason, there are no errors in logCat. When I used this code with Activity everything works well. Is it all about a fragment or the navigation library?</p>
  
  <p>My ViewModel</p>
  
  <pre><code>class AuthViewModel @Inject constructor(private var mAuth: FirebaseAuth) : ViewModel() {
  
      var mEmail: String = ""
      var mPassword: String = ""
  
      var loginListener: LoginListener? = null
  
      fun login(view: View) {
          if (mEmail.isNotEmpty() &amp;&amp; mPassword.isNotEmpty()) {
              mAuth = FirebaseAuth.getInstance()
              mAuth.signInWithEmailAndPassword(mEmail, mPassword).addOnCompleteListener {
                  if (it.isSuccessful) {
                      loginListener?.startLoading()
                      android.os.Handler().postDelayed({
                          loginListener?.endLoading()
                          loginListener?.validateLoginAndPassword()
                      }, 500)
                  } else {
                      loginListener?.showError(textResource = R.string.login_error)
                  }
              }
          } else {
              loginListener?.showError(textResource = R.string.login_or_password_empty)
          }
      }
  }
  </code></pre>
  
  <p>My Fragment</p>
  
  <pre><code>class LoginFragment : DaggerFragment(), View.OnClickListener, KeyboardVisibilityEventListener, LoginListener {
  
      private lateinit var navController: NavController
      lateinit var binding: FragmentLoginBinding
  
      @Inject
      lateinit var factory: ViewModelProvider.Factory
      lateinit var mAuthViewModel: AuthViewModel
  
      override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
          savedInstanceState: Bundle?): View? {
          binding = FragmentLoginBinding.inflate(inflater, container, false)
          return binding.root
      }
  
      override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
          super.onViewCreated(view, savedInstanceState)
          navController = Navigation.findNavController(view)
          view.btn_registration.setOnClickListener(this)
  
          mAuthViewModel = ViewModelProviders.of(this@LoginFragment, factory).get(AuthViewModel::class.java)
  
      }
  
      override fun onClick(view: View?) {
          when(view!!.id) {
              R.id.btn_registration -&gt; navController.navigate(R.id.action_loginFragment_to_registerFragment)
  
          }
      }
  
      override fun validateLoginAndPassword() {
          //startActivity(Intent(activity, ContactListActivity::class.java))
  
          val intent = Intent(activity, ContactListActivity::class.java)
          startActivity(intent)
      }
  </code></pre>
  
  <p>My LoginFragment XML</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;layout
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"&gt;
  
      &lt;data&gt;
          &lt;variable
              name="loginViewModel"
              type="com.infernal93.phonebookappmvvmanddagger.viewmodels.AuthViewModel" /&gt;
      &lt;/data&gt;
  
      &lt;FrameLayout
  
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:focusableInTouchMode="true"
          tools:context=".view.fragments.LoginFragment"&gt;
  
          &lt;ScrollView
              android:id="@+id/root_scroll_view"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:fillViewport="true"
              android:scrollbars="none"&gt;
  
              &lt;RelativeLayout
                  android:layout_width="match_parent"
                  android:layout_height="wrap_content"
                  android:focusable="true"
                  android:focusableInTouchMode="true" &gt;
  
                  &lt;EditText
                      android:id="@+id/login_email"
                      android:layout_width="300dp"
                      android:layout_height="50dp"
                      android:layout_centerHorizontal="true"
                      android:layout_marginTop="200dp"
                      android:background="@drawable/bg_inputs"
                      android:ems="10"
                      android:hint="@string/email_text"
                      android:text="@={loginViewModel.mEmail}"
                      android:inputType="textEmailAddress"
                      android:textColorHint="@color/dark_gray" /&gt;
  
                  &lt;EditText
                      android:id="@+id/login_password"
                      android:layout_width="300dp"
                      android:layout_height="50dp"
                      android:layout_below="@id/login_email"
                      android:layout_centerHorizontal="true"
                      android:layout_marginTop="10dp"
                      android:background="@drawable/bg_inputs"
                      android:hint="@string/password_text"
                      android:text="@={loginViewModel.mPassword}"
                      android:inputType="textPassword"
                      android:textColorHint="@color/dark_gray" /&gt;
  
                  &lt;com.github.rahatarmanahmed.cpv.CircularProgressView
                      android:id="@+id/cpv_login"
                      android:layout_width="@dimen/cpv_size"
                      android:layout_height="@dimen/cpv_size"
                      android:layout_below="@id/login_password"
                      android:layout_centerHorizontal="true"
                      android:layout_marginTop="15dp"
                      android:visibility="gone"
                      app:cpv_animAutostart="true"
                      app:cpv_color="@color/colorPrimary"
                      app:cpv_indeterminate="true" /&gt;
  
                  &lt;Button
                      android:id="@+id/btn_login_enter"
                      android:layout_width="250dp"
                      android:layout_height="50dp"
                      android:layout_below="@id/cpv_login"
                      android:layout_centerHorizontal="true"
                      android:layout_marginTop="20dp"
                      android:background="@drawable/bg_buttons"
                      android:text="@string/login_btn_text"
                      android:textAllCaps="false"
                      android:textColor="@color/white"
                      android:textSize="@dimen/login_btns_text_size"
                      android:onClick="@{(view) -&gt; loginViewModel.login(view)}"/&gt;
  
                  &lt;Button
                      android:id="@+id/btn_registration"
                      android:layout_width="250dp"
                      android:layout_height="50dp"
                      android:layout_below="@id/btn_login_enter"
                      android:layout_centerHorizontal="true"
                      android:layout_marginTop="20dp"
                      android:background="@drawable/bg_buttons"
                      android:text="@string/registration_btn_text"
                      android:textAllCaps="false"
                      android:textColor="@color/white"
                      android:textSize="@dimen/login_btns_text_size" /&gt;
              &lt;/RelativeLayout&gt;
  
          &lt;/ScrollView&gt;
  
      &lt;/FrameLayout&gt;
  
  &lt;/layout&gt;
  </code></pre>