Advanced Data Binding - Google I/O 2016

Android Developers · 32K views · 2016 · 40:16

Open on YouTube

Software architecture & designSoftware practice, open source & careerstalkdated

Why Stack Overflow recommends it

Stack Overflow users link it when answering Android data binding questions, especially for two-way binding syntax (@=), inverse binding adapters and why to adopt data binding.

Recommended by 4 people across 4 different months, 2016 to 2017.

What it is

A 40-minute Google I/O 2016 session from the Android team on Android Data Binding. It covers new features such as two-way binding and lambda expressions, the design decisions behind the architecture, and how binding works with animations, RecyclerView and dependency injection, plus best practices.

What people said

Recommends Matthew Horst · 2016-09 · Stack Overflow · on “Sync "pause/resume" button's image with the actual state”

I don't think your solution is bad. However, another way that is arguably better would be to use Android data binding. The way this would work is, make a model object that represents the service state. E.g. Player.isPlaying, representing the service state. Then in the service, you would set the isPlaying state. Then in your layout, you would use data binding to link that model object isPlaying state to the UI, however you want to set it, for example: android:background="@{player.isPlaying ? @drawable/pause : @drawable/play}" The reason I think this might be a better solution is, it links up the UI state directly 1:1 with the service. Conceptually I imagine a broadcast as being able to come f

Recommends CommonsWare · 2016-12 · Stack Overflow · on “why use Databinding?”

"do i have or need to change all my code to Databinding Syntax" -- only where you want to use data binding. "is it necessary" -- no. "will it make my application more secure" -- no. "i have read somewhere that it will minimize the code and i dont have to write findviewbyid for every view or settext in most of the cases" -- correct. I recommend watching this video [LINK] and this video [this video] to learn why data binding may be useful to you.

Recommends OnJohn · 2017-02 · Stack Overflow · on “Android Data Binding - Reference to view”

I think this should be the answer. Much simpler and sticked with Google documents. For people want more info, they may refer to below answer and Google IO 2016. [LINK] [this video]

Recommends Bartek Lipinski · 2017-03 · Stack Overflow · on “When should InverseBindingAdapter be used?”

The word Inverse is really saying everything you need to know, if you think of what DataBinding is actually doing. If you enable DataBinding for your Layout you can perceive it as a pair of two things: View (all Views included in <layout></layout> ) Model (all variables included in <data></data> ) Regular DataBinding makes sure that a change in the Model will have its effects in the View . It is invoked by @{expression} . Inverse DataBinding makes sure that a change in the View will have its effects in the Model . It is invoked by @={expression} (the = char is essential here). If you think what are the ways to make a change in the View , those can be: Changes in content (e.g. text in TextVie

Cites GinsengRoses · 2016-05 · Stack Overflow · on “Android Data Binding how to get user entered text and get it in code”

According to George and Yigit's Google I/O 2016 [this video] data binding talk, you can do: android:text="@={User.LogIn} In your xml and the two way will work. The thing to note is the additional equals sign.

Cites chubao · 2016-06 · Stack Overflow · on “Cannot refer to other View ID in Android data binding”

I just finished watching Advanced Data Binding - Google I/O 2016 [this video] and would like to apply the following to reduce repetition of my expression used in different views. [LINK] But I cannot make it work in my case: <ImageButton android:id="@+id/btn_list" android:layout_width="48dp" android:layout_height="48dp" android:layout_gravity="start" android:background="@drawable/btn_s01_list" android:visibility="@{bean.shouldHideControls? View.GONE: View.VISIBLE}"/> <ToggleButton android:id="@+id/btn_radar" android:layout_width="48dp" android:layout_height="48dp" android:background="@drawable/btn_radar_selector" android:checked="false" android:gravity="end" android:text="" android:textOff="" andr