Q:

Android databinding does not refresh the changes how can do it?

I have the next code
build.gradle
dataBinding {
    enabled = true
}

implementation "android.arch.lifecycle:extensions:$lifecycle_version"

LoginActivity.java
import android.arch.lifecycle.Observer;
import android.arch.lifecycle.ViewModelProviders;
import android.databinding.DataBindingUtil;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;

import com.theapp.R;
import com.theapp.databinding.ActivityLoginBinding;

public class LoginActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ActivityLoginBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_login);
        LoginViewModel loginViewModel = ViewModelProviders.of(this).get(LoginViewModel.class);
        binding.setLoginViewModel(loginViewModel);
        binding.setLifecycleOwner(this);

        loginViewModel.email.observe(this, new Observer<String>() {
            @Override
            public void onChanged(@Nullable String email) {
                Toast.makeText(getApplicationContext(), email, Toast.LENGTH_LONG);
            }
        });

    }
}

activity_login.xml
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:tools="http://schemas.android.com/tools"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <data> <variable name="loginViewModel" type="com.theapp.login.LoginViewModel" /> </data>
    <android.support.constraint.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".login.LoginActivity">

        <EditText
            android:id="@+id/etxtEmail"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginTop="16dp"
            android:layout_marginEnd="16dp"
            android:layout_marginBottom="16dp"
            android:ems="10"
            android:text="@{loginViewModel.email}"
            android:inputType="textEmailAddress"
            android:hint="@string/email"
            app:layout_constraintBottom_toTopOf="@+id/etxtPassword"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_chainStyle="packed" />

        <EditText
            android:id="@+id/etxtPassword"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginTop="16dp"
            android:layout_marginEnd="16dp"
            android:layout_marginBottom="16dp"
            android:ems="10"
            android:text="@{loginViewModel.email}"
            android:inputType="textPassword"
            android:hint="@string/password"
            app:layout_constraintBottom_toTopOf="@+id/btnRegister"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/etxtEmail" />

        <Button
            android:id="@+id/btnRegister"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="16dp"
            android:layout_marginTop="16dp"
            android:layout_marginEnd="16dp"
            android:layout_marginBottom="16dp"
            android:text="@string/login"
            android:onClick="@{()-> loginViewModel.onLoginClicked()}"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/etxtPassword" />
    </android.support.constraint.ConstraintLayout>

</layout>

LoginViewModel.java
package com.theapp.login;

import android.arch.lifecycle.MutableLiveData;
import android.arch.lifecycle.ViewModel;
import android.util.Log;

import com.theapp.models.User;
import com.theapp.repository.network.APIClient;
import com.theapp.repository.network.APIInterface;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class LoginViewModel extends ViewModel {

    private APIInterface apiInterface;

    public MutableLiveData<String> email = new MutableLiveData<>();
    public MutableLiveData<String> password = new MutableLiveData<>();

    public LoginViewModel() {

    }
}

When I put data in the email text in layout, I want to be able to use that data in the password field, but also in the activity with the toast, however, it does not do anything.
I copied the code almost in its entirety of this link, I have left in both projects the same classes and in mine it does not work, I do not know if it is because of the dependencies of the gradle, or for something unknown.
Any ideas?

A:

this is one-way data-binding:
android:text="@{loginViewModel.email}"

the syntax for two-way data-binding looks alike this:
android:text="@={loginViewModel.email}"

this Q & A seems related.

