Skip to content

alidabour/DataBinding2

Repository files navigation

DataBinding2

Collecting examples about Android Databinding

Two Way binding

TwoBindingActivity display two parallel fragments, EditFragment(Yellow) and ViewingFragment(Green), both fragment use same viewModel where data entered in EditFragment are observed into ViewingFramgment. Example contians : EditText, Visibility trigger,SeekBar and Spinner

Implicit Attribute Listeners

You can also reference attributes on other Views:

 <layout ...>
  <data>
    <import type="android.view.View"/>
  </data>
  <RelativeLayout ...>
    <CheckBox android:id="@+id/seeAds" .../>
    <ImageView android:visibility="@{seeAds.checked ? View.VISIBLE : View.GONE}" .../>
  </RelativeLayout>
</layout>

In the above, whenever the checked state of CheckBox changes, the ImageView’s visibility will change. No need to attach a listener on your own! This kind of expression only works with attributes that support 2-way data binding and those that have binding expressions. halfthought blog , code example

Releases

No releases published

Packages

No packages published

Languages