title: LiveData and ViewModel does not update textview
body: <p>I am having a small issue, when i comment out the <strong>binding.setData(dataContainer);</strong> in <strong>onChanged</strong> while observing Livedata in my Activity, I am not able to update the UI, <em>when I uncomment it, the UI is updated.</em>
  Please guide and do a little code review if you feel the need.</p>
  
  <p>I am having a Runnable that runs repeatedly after every x seconds. This is made Livedata which I observe in my Activity.</p>
  
  <p>Thanks.</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
    TextOnScreen dataContainer;
    ActivityMainBinding binding;
    ViewModelClass modelClass;
  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      modelClass = ViewModelProviders.of(this).get(ViewModelClass.class);
      binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
      dataContainer = new TextOnScreen("hello");
      binding.setData(dataContainer);
  
      modelClass.getLiveData().observe(this, new Observer&lt;String&gt;() {
        @Override
        public void onChanged(String s) {
          Log.e("TAG", "--onChanged--" + s);
          dataContainer.onscreen.set(s);
  
          // this line allows the textview to update
          // other wise no change on UI is seen
          binding.setData(dataContainer);
        }
      });
    }
  }
  
  
  public class TextOnScreen {
  
    public final ObservableField&lt;String&gt; onscreen=new ObservableField&lt;&gt;();
  
    public TextOnScreen(String t) {
      onscreen.set(t);
    }
  
    public String getOnscreen() {
      return onscreen.get();
    }
  
    public void setOnscreen(String onscreen) {
      this.onscreen.set(onscreen);
    }
  }
  
  
      public class ViewModelClass extends ViewModel{
  
        private MutableLiveData&lt;String&gt; liveData;
  
        public ViewModelClass() {
          ModelClass modelClass = new ModelClass();
          liveData= modelClass.generateName();
        }
  
        public LiveData&lt;String&gt; getLiveData() {
          return liveData;
        }
      }
  
  
  public class ModelClass {
  
    MutableLiveData&lt;String &gt; data =new MutableLiveData&lt;&gt;();
  
  
    MutableLiveData&lt;String&gt; generateName(){
      final android.os.Handler handler=new android.os.Handler();
      Runnable runnable=new Runnable() {
        @Override
        public void run() {
  
          data.setValue(data.getValue()+"*");
          handler.postDelayed(this,1000);
        }
      };
      handler.postDelayed(runnable,2000);
      return data;
    }
  
  }
  
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;layout&gt;
    &lt;data&gt;
      &lt;variable
        name="data"
        type="dsfa.drish.com.livedatasample.TextOnScreen"/&gt;
    &lt;/data&gt;
  &lt;android.support.constraint.ConstraintLayout
    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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity"&gt;
  
    &lt;TextView
      android:id="@+id/textview"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@{data.onscreen}"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintLeft_toLeftOf="parent"
      app:layout_constraintRight_toRightOf="parent"
      app:layout_constraintTop_toTopOf="parent"/&gt;
  
  &lt;/android.support.constraint.ConstraintLayout&gt;
  &lt;/layout&gt;
  </code></pre>