title: Android - data binding on a property of an LiveData extended object
body: <p>I currently started to use the Data Binding Library and in my viewmodel I have an extended LiveData object:</p>
  <pre><code>public class ScannerViewModel extends AndroidViewModel {
  
      /** MutableLiveData containing the scanner state to notify MainActivity. */
      public ScannerLiveData scannerLiveData;
  </code></pre>
  <p><strong>ScannerLiveData:</strong></p>
  <pre><code>public class ScannerLiveData extends MutableLiveData&lt;ScannerLiveData&gt; {
      public boolean mScanningStarted;
      public boolean mBluetoothEnabled;
      public boolean mLocationEnabled;
  
      public ScannerLiveData(final boolean bluetoothEnabled, final boolean locationEnabled) {
          mScanningStarted = false;
          mBluetoothEnabled = bluetoothEnabled;
          mLocationEnabled = locationEnabled;
          postValue(this);
      }
      ...
  }
  </code></pre>
  <p><strong>activity_scanner.xml:</strong></p>
  <pre><code>&lt;layout
      xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      android:id=&quot;@+id/layout_test&quot;&gt;
  
      &lt;data&gt;
          &lt;import type=&quot;android.view.View&quot; /&gt;
  
          &lt;variable
              name=&quot;livedata&quot;
              type=&quot;de.datacollect.ecount.ui.scanner.ScannerLiveData&quot; /&gt;
      &lt;/data&gt;
              
      ...
      &lt;android.support.constraint.ConstraintLayout
          &lt;ProgressBar
              android:id=&quot;@+id/state_scanning&quot;
              style=&quot;?android:attr/progressBarStyleHorizontal&quot;
              android:layout_width=&quot;match_parent&quot;
              android:layout_height=&quot;wrap_content&quot;
              android:layout_marginBottom=&quot;-7dp&quot;
              android:layout_marginTop=&quot;-8dp&quot;
              android:indeterminate=&quot;true&quot;
              android:indeterminateTint=&quot;@android:color/white&quot;
              android:visibility=&quot;@{livedata.mBluetoothEnabled ? View.VISIBLE : View.INVISIBLE}&quot;
              app:layout_constraintEnd_toEndOf=&quot;parent&quot;
              app:layout_constraintStart_toStartOf=&quot;parent&quot;
              app:layout_constraintTop_toTopOf=&quot;@+id/recycler_view_ble_devices&quot; /&gt;
          ...
  </code></pre>
  <p><strong>ScannerActivity:</strong></p>
  <pre><code>@Override
  protected void onCreate(@Nullable final Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      ActivityScannerBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_scanner);
  
      // Create view model containing utility methods for scanning
      mScannerViewModel = ViewModelProviders.of(this).get(ScannerViewModel.class);
      mScannerViewModel.getScannerState().observe(this, this::startScan);
      
      binding.setLifecycleOwner(this);
      binding.setLivedata(mScannerViewModel.scannerLiveData);
      ...
  </code></pre>
  <p>How can I bind to the <code>mBluetoothEnabled</code> property? I get an unclassified error on build. I already used the search but didn't find something about it. Every help would be appreciate.</p>
  <p>Btw:</p>
  <blockquote>
  <p>Updates to Data Binding:</p>
  <p>You can now use a LiveData object as an observable field in data binding expressions. The ViewDataBinding class now includes a new setLifecycle method that you need to use to use to observe LiveData objects.</p>
  </blockquote>