title: Android checkboxes not checked correctly in ViewPager with data binding
body: <p>I have a form in my Android app that is spread across multiple pages with a ViewPager. </p>
  
  <p>To keep it simple, it just returns View-objects instead of instantiating Fragments.</p>
  
  <p>Each view is made of a layout and a viewmodel (The same instance I use for all the views) and data binding to set the values automatically.</p>
  
  <p>The problem is that the checkboxes is not filled and have a white checkmark if they are in a view that is not in the front when loading the activity.</p>
  
  <p>If I change the order, so my view with the checkboxes are the first one loaded by the ViewPager, I can see the checkboxes being checked (with an animation) and they are marked correctly.</p>
  
  <p>See the attached screenshots:</p>
  
  <p><a href="https://i.stack.imgur.com/yQLsy.png" rel="noreferrer">View not being the first loaded</a></p>
  
  <p><a href="https://i.stack.imgur.com/cLLcl.png" rel="noreferrer">View being the first loaded</a></p>
  
  <p>I have the same problem with radio buttons.</p>
  
  <p>An example of a Checkbox's databinding:</p>
  
  <pre><code>&lt;CheckBox
              android:id="@+id/checkbox_calling"
              android:layout_width="0dp"
              android:layout_height="wrap_content"
              android:layout_marginTop="16dp"
              android:layout_weight="1"
              android:checked="@={viewModel.observation.calling}"
              android:text="@string/label_calling" /&gt;
  </code></pre>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>I have currently solved the problem by setting a <code>OnPageChangeListener</code> on the <code>ViewPager</code> and when the <code>ViewPager</code> scrolls to the page with the checkboxes, I uncheck the checkboxes and then set them to the original value.</p>
  
  <p>The animation is then shown correctly and the checkboxes ends up with the correct checkmarks.</p>
  
  <p>I would however still appreciate finding out what I've done wrong or if there is a problem with Android databinding itself.</p>