Android Data Binding Library Built-in two-way Data Binding

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Two-way Data-Binding supports the following attributes:

ElementProperties
AbsListViewandroid:selectedItemPosition
CalendarViewandroid:date
CompoundButtonandroid:checked
DatePicker
  • android:year
  • android:month
  • android:day
EditTextandroid:text
NumberPickerandroid:value
RadioGroupandroid:checkedButton
RatingBarandroid:rating
SeekBarandroid:progress
TabHostandroid:currentTab
TextViewandroid:text
TimePicker
  • android:hour
  • android:minute
ToggleButtonandroid:checked
Switchandroid:checked

Usage

<layout ...>
    <data>
        <variable type="com.example.myapp.User" name="user"/>
    </data>
    <RelativeLayout ...>
        <EditText android:text="@={user.firstName}" .../>
    </RelativeLayout>
</layout>

Notice that the Binding expression @={} has an additional =, which is necessary for the two-way Binding. It is not possible to use methods in two-way Binding expressions.



Got any Android Question?